I have the following InspectorGUI code for a custom Button class:
public override void OnInspectorGUI() {
serializedObject.Update();
EditorGUILayout.PropertyField(serializedObject.FindProperty("onClick"), true);
serializedObject.ApplyModifiedProperties();
}
However FindProperty appears to be returning null:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.PropertyHandler.OnGUILayout (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at <3e481e8f36eb4d4c8d94b9ba6b2be438>:0)
UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at <3e481e8f36eb4d4c8d94b9ba6b2be438>:0)
UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at <3e481e8f36eb4d4c8d94b9ba6b2be438>:0)
MainMenuButtonEditor.OnInspectorGUI () (at Assets/Editor/MainMenuButtonEditor.cs:16)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass55_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <3e481e8f36eb4d4c8d94b9ba6b2be438>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)