I’m getting a weird issue with custom Editors and UnityEvents.
Here’s the setup
- ComponentA has a UnityEvent property.
- ComponentB has a public property “componentA” which references an instance of ComponentA.
- ComponentB has a custom Editor defined. In ComponentBEditor.OnInspectorGUI(), I’m using Editor.CreateEditor(componentA) to inspect the properties of componentA, by calling DrawDefaultInspector() on the created Editor.
The created Editor works perfectly for any type of property I put in ComponentA, but as soon as I add a UnityEvent property I get the following console error. Am I missing something or is this a bug?
NullReferenceException: SerializedObject of SerializedProperty has been Disposed.
UnityEditorInternal.ReorderableList.get_count ()
UnityEditorInternal.ReorderableList.GetListElementHeight ()
UnityEditorInternal.ReorderableList.GetHeight ()
UnityEditorInternal.UnityEventDrawer.GetPropertyHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
UnityEditor.PropertyDrawer.GetPropertyHeightSafe (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
UnityEditor.PropertyHandler.GetHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, Boolean includeChildren)
UnityEditor.PropertyHandler.OnGUILayout (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, Boolean includeChildren, UnityEngine.GUILayoutOption[ ] options)
UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, Boolean includeChildren, UnityEngine.GUILayoutOption[ ] options)
UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, Boolean includeChildren, UnityEngine.GUILayoutOption[ ] options)
UnityEditor.Editor.DoDrawDefaultInspector (UnityEditor.SerializedObject obj)
UnityEditor.Editor.DoDrawDefaultInspector ()
UnityEditor.Editor.DrawDefaultInspector ()