Hi all,
I’m an experienced C# dev but new to Unity. For some reason I just can’t get a simple Inspector to work in the editor. Even using the sample code at:
Perhaps I don’t understand this correctly. I have a class “/Assets/Scripts/CameraBarrier.cs” which inherits from MonoBehavior. This class is supposed to contain a path which limits the area my camera can move in.
Next I have a class: “/Assets/Editor/CameraBarrierEditor.cs” which inherits from Editor. This would have an on OnSceneGUI method.
However in Unity if I add the script to an empty GameObject and click on the game object, I get “Instance of CameraBarrierEditor couldn’t be created. The script class needs to derive from ScriptableObject and be placed in the Assets/Editor folder.”
I’ve tried examples that use js files and they seem to work.
The Editor code looks like this:
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace UnityEditor
{
[CustomEditor(typeof(CameraBarrier))]
public class CameraBarrierEditor : Editor
{
override public void OnInspectorGUI()
{
}
public void OnSceneGUI()
{
}
}
}
And the script class:
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class CameraBarrier : MonoBehaviour
{
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
Any ideas?
Thanks