private static void OnSelectionChanged()
        {
            if (!SceneKeeperTools.IsSelectionKeeperActive())
            {
                return;
            }

            if (!UnityHierarchyTools.IsHierarchyWindowOpen())
            {
                return;
            }

            if (Selection.objects.Length == 0)
            {
                if (EditorWindow.focusedWindow == UnityHierarchyTools.HierarchyWindow)
                {
                    for (int i = 0; i < SceneManager.sceneCount; i++)
                    {
                        Scene scene = SceneManager.GetSceneAt(i);
                        if (!SelectionHistory.ContainsKey(scene))
                        {
                            continue;
                        }

                        SelectionHistory[scene].Clear();
                    }
                }
                return;
            }

            ClearedSceneChangeLists.Clear();
            for (int i = 0; i < Selection.objects.Length; i++)
            {
                Object selectedObject = Selection.objects[i];
                if (selectedObject is GameObject selectedGameObject)
                {
                    Scene selectedGameObjectScene = selectedGameObject.scene;

                    if (!SelectionHistory.ContainsKey(selectedGameObjectScene))
                    {
                        SelectionHistory.Add(selectedGameObjectScene, new List <GameObject>());
                    }
                    else
                    {
                        if (!ClearedSceneChangeLists.Contains(selectedGameObjectScene))
                        {
                            SelectionHistory[selectedGameObjectScene].Clear();
                            ClearedSceneChangeLists.Add(selectedGameObjectScene);
                        }
                    }

                    SelectionHistory[selectedGameObjectScene].Add(selectedGameObject);
                }
            }
        }
        private static void SaveFromAllOpenScenes()
        {
            if (!UnityHierarchyTools.IsHierarchyWindowOpen())
            {
                return;
            }

            for (int i = 0; i < SceneManager.sceneCount; i++)
            {
                StoreScenedData(SceneManager.GetSceneAt(i));
            }
        }
        private static void RestoreFromAllOpenScenes()
        {
            EditorApplication.update -= RestoreFromAllOpenScenes;

            if (!UnityHierarchyTools.IsHierarchyWindowOpen())
            {
                return;
            }

            for (int i = 0; i < SceneManager.sceneCount; i++)
            {
                RestoreSceneData(SceneManager.GetSceneAt(i));
            }
        }
        private static void RestoreSceneData(Scene scene)
        {
            if (scene.buildIndex == -1)
            {
                return;
            }

            if (!UnityHierarchyTools.IsHierarchyWindowOpen())
            {
                return;
            }

            HashSet <string> alreadySelectedGameObjectPaths = new HashSet <string>();

            RestoreSelectionData(scene, ref alreadySelectedGameObjectPaths);
            RestoreHierarchyData(scene, ref alreadySelectedGameObjectPaths);
        }
        private static void StoreScenedData(Scene targetScene)
        {
            if (targetScene.buildIndex == -1)
            {
                return;
            }

            if (!UnityHierarchyTools.IsHierarchyWindowOpen())
            {
                return;
            }

            HashSet <GameObject> alreadySelectedGameObjects = new HashSet <GameObject>();

            StoreSelectionData(targetScene, ref alreadySelectedGameObjects);
            StoreHierarchyData(targetScene, ref alreadySelectedGameObjects);

            SaveData();
        }