Editor class...

I am a MegaNoob on this front…

I am trying to use an example editor script, to get on my feet, and understand the concept…

@CustomEditor(MyPlayerEditor)
class MyPlayerEditor extends Editor
{
    function OnInspectorGUI()
    {
        EditorGUILayout.BeginHorizontal ();
        EditorGUILayout.PrefixLabel ("Speed");
        target.speed = EditorGUILayout.Slider (target.speed, 0, 100);
        EditorGUILayout.EndHorizontal ();

        EditorGUILayout.BeginHorizontal ();
        EditorGUILayout.PrefixLabel ("Ammo");
        target.ammo = EditorGUILayout.IntField (target.ammo);
        EditorGUILayout.EndHorizontal ();
    }
}

Apparently this code is supposed to be a custom inspector - but I can’t find the inspector anywhere! If I understand correctly, it is supposed to display in a manner similar to the Game View, Hierarchy, Inspector, etcetera. However, as I have said, I can’t find it anywhere to display in the first place! I have made sure it is under the “Editor” folder.

Any help?

Custom inspectors appear in the same place as the regular inspector. Where you’d normally see the component’s public variables, you’re instead shown whatever GUI elements you specify in the OnInspectorGUI() function.

If the component you’re writing a custom inspector for is named MyPlayer, then use @CustomEditor(MyPlayer) rather than @CustomEditor(MyPlayerEditor). I’m guessing this is the reason the code isn’t working for you.

Thanks! I’ll try that.