private static void RestoreSelectionData(Scene scene, ref HashSet <string> alreadySelectedGameObjectPaths)
        {
            if (!SceneKeeperTools.IsSelectionKeeperActive())
            {
                return;
            }

            if (!SceneData.TryGetSceneSelectionData(scene.path, out SelectionData resultSelectionData))
            {
                return;
            }

            List <Object> selectedObjects = new List <Object>();

            for (int i = 0; i < resultSelectionData.itemPath.Count; i++)
            {
                string targetItemPath = resultSelectionData.itemPath[i];
                if (TryToFindBySceneRootObjects(scene, targetItemPath, out GameObject targetGameObject))
                {
                    selectedObjects.Add(targetGameObject);
                    alreadySelectedGameObjectPaths.Add(targetItemPath);
                }
            }

            if (selectedObjects.Count > 0)
            {
                Selection.objects = selectedObjects.ToArray();
            }
        }
        private static void StoreSelectionData(Scene targetScene, ref HashSet <GameObject> alreadySelectedGameObjects)
        {
            if (!SceneKeeperTools.IsSelectionKeeperActive())
            {
                return;
            }

            if (Application.isPlaying && SceneKeeperTools.IsIgnoringPlaytimeSelection())
            {
                return;
            }

            if (!TryGetLastValidSelectionForScene(targetScene, out List <GameObject> selectedGameObjects))
            {
                return;
            }

            SelectionData sceneSelectionData = SceneData.GetOrAddSceneSelectionData(targetScene.path);

            sceneSelectionData.itemPath.Clear();

            for (int i = 0; i < selectedGameObjects.Count; i++)
            {
                GameObject selectedGameObject = selectedGameObjects[i];
                if (selectedGameObject == null)
                {
                    continue;
                }

                sceneSelectionData.itemPath.Add(selectedGameObject.transform.GetPath());

                alreadySelectedGameObjects.Add(selectedGameObject);
            }
        }
        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);
                }
            }
        }