void OnStageChanged(Stage previousStage, Stage newStage) { if (previousStage is MainStage) { previousStage.SaveHierarchyState(m_SceneHierarchyWindow); // Non-main stages are saved before they are destroyed } newStage.SyncSceneHierarchyToStage(m_SceneHierarchyWindow); newStage.LoadHierarchyState(m_SceneHierarchyWindow); m_StageHeaderContent = GUIContent.none; // Stage header content is being rebuild on demand in a OnGUI code path (required since it uses EditorStyles) if (m_SceneHierarchyWindow.hasSearchFilter) { m_SceneHierarchyWindow.SetSearchFilter(string.Empty, m_SceneHierarchyWindow.searchMode, true); m_SceneHierarchyWindow.UnfocusSearchField(); } }