Editor/DefaultEditorUtility.cs
/// <summary>
/// To be called in the OnDisable of CustomInspectors.
/// </summary>
/// <param name="defaultEditor">The defaultEditor created in the OnEnable method.</param>
To be called in the OnDisable of CustomInspectors.
To be called in the OnDisable of CustomInspectors .
public static void DestroyDefaultEditor(UnityEditor.Editor defaultEditor)
        {
            MethodInfo disableMethod = defaultEditor.GetType().GetMethod("OnDisable", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            if (disableMethod != null)
            {
                disableMethod.Invoke(defaultEditor, null);
            }
            Object.DestroyImmediate(defaultEditor);
        }
public static void DestroyDefaultEditor ( UnityEditor . Editor defaultEditor ) { MethodInfo disableMethod = defaultEditor . GetType ( ) . GetMethod ( " " , BindingFlags . Instance | BindingFlags . NonPublic | BindingFlags . Public ) ; if ( disableMethod != null ) { disableMethod . Invoke ( defaultEditor , null ) ; } Object . DestroyImmediate ( defaultEditor ) ; }
To be called in the OnDisable of CustomInspectors.
To be called in the OnDisable of CustomInspectors .
// When OnDisable is called, the default editor we created should be destroyed to avoid memory leakage. // Also, make sure to call any required methods like OnDisable
defaultEditor
UnityEditor.Editor
The defaultEditor created in the OnEnable method.
The defaultEditor created in the OnEnable method .