CustomEditor的文件要放在Assets/Editor目录下

时间:2023-01-25 23:06:26
using UnityEditor;
using UnityEngine; [CustomEditor(typeof(test))]
public class testEditor : Editor
{
void OnEnable()
{
} public override void OnInspectorGUI()
{
test myTarget = (test)target;
myTarget.MyValue = EditorGUILayout.IntSlider(
"Val-you", myTarget.MyValue, , );
}
}

照网上写的代码,报错,后来发现这个文件要放到Assets/Editor目录下
Instance of testEditor couldn't be created. The script class needs to derive from ScriptableObject and be placed in the Assets/Editor folder.