- Home /
Why isn't my CustomEditor's OnInspectorGUI() running?
Hi,
I hope someone can help. I've been scouring the forums, working on a solution and I think I'm just missing something. The OnInspectorGUI in my CustomEditor is never being run. I placed a breakpoint inside and it doesn't get hit. Here's my code. Any advice is GREATLY appreciated!
using System;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(Row))]
public class RowEditor : Editor {
bool toggle1, toggle2, toggle3, toggle4;
public override void OnInspectorGUI() {
GUILayoutOption toggleOption = GUILayout.Width (EditorGUIUtility.currentViewWidth / 4);
EditorGUILayout.BeginHorizontal ();
toggle1 = EditorGUILayout.Toggle ("", toggle1, toggleOption);
toggle2 = EditorGUILayout.Toggle ("", toggle2, toggleOption);
toggle3 = EditorGUILayout.Toggle ("", toggle3, toggleOption);
toggle4 = EditorGUILayout.Toggle ("", toggle4, toggleOption);
EditorGUILayout.EndHorizontal ();
}
}
using System;
using UnityEngine;
[Serializable]
public class Row : ScriptableObject {
public bool track1;
public bool track2;
public bool track3;
public bool track4;
}
using UnityEngine;
using System.Collections;
public class SpawnManager : MonoBehaviour {
public Row spawnRow;
}
The editor script is in Assets > Scripts > Editor ... The others are in in Assets > Scripts > ScriptableObjects and Assets > Scripts
Answer by Adam-Mechtley · Dec 13, 2016 at 12:47 PM
This editor will be displayed when you have a Row asset selected. It will not appear when you have your SpawnManager selected, as you will just see an object reference field. You need to either:
Add CreateAssetMenuAttribute to your Row class and then create one in your project to select or
Make Row inherit from System.Object and create a custom PropertyDrawer for it, rather than creating a custom Editor for it
I did not realize that. Thank you very much. You saved me a lot of additional time.
Your answer
Follow this Question
Related Questions
Custom Inspector doesn't show changes immediatley 2 Answers
Drag from custom editor ObjectField 0 Answers
Calling OnValidate on a ScriptableObject with a list of ScriptableObjects 1 Answer
[Custom Editor] MonoBehaviour vs Scriptable Object 0 Answers
Object field not working in custom editor for scriptable object? 0 Answers