private void Dispose() { if (!m_isDisposed) { if (m_graph != null) { BTEditorGraph.DestroyImmediate(m_graph); m_graph = null; } if (m_btAsset != null) { SaveBehaviourTree(); m_btAsset.Dispose(); m_btAsset = null; } m_rootTreeAsset = null; EditorApplication.playmodeStateChanged -= HandlePlayModeChanged; Selection.selectionChanged -= delegate { SetupBTDebugging(); }; m_isDisposed = true; } }