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

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, 1, 10);
    }
}

照网上写的代码,报错,后来发现这个文件要放到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.

原文地址:https://www.cnblogs.com/xbglbc/p/3371831.html