void Shutdown(bool finalizing = false) { if (editor != this) { return; } editor = null; CSGSceneManagerRedirector.Interface = null; if (!initialized) { return; } EditorApplication.update -= OnFirstUpdate; EditorApplication.hierarchyWindowChanged -= OnHierarchyWindowChanged; EditorApplication.hierarchyWindowItemOnGUI -= HierarchyWindowItemGUI.OnHierarchyWindowItemOnGUI; SceneView.onSceneGUIDelegate -= SceneViewEventHandler.OnScene; Undo.undoRedoPerformed -= UndoRedoPerformed; initialized = false; // make sure the C++ side of things knows to clear the method pointers // so that we don't accidentally use them while closing unity NativeMethodBindings.ClearUnityMethods(); NativeMethodBindings.ClearExternalMethods(); if (!finalizing) { SceneToolRenderer.Cleanup(); } }