private static void ResetHierarchyToExpandedState()
        {
            if (_allExpandedIDs == null)
            {
                return;
            }

            if (NSelection.HierarchyWindow == null)
            {
                return;
            }

            NSelection.SetHierarchyToState(new List <int>(_allExpandedIDs));
        }
        private static void ResetHierarchyToExpandedStateExcept(GameObject gameObject)
        {
            if (_allExpandedIDs == null)
            {
                return;
            }

            if (NSelection.HierarchyWindow == null)
            {
                return;
            }

            var newState = new List <int>(_allExpandedIDs);

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

            NSelection.CollectParents(gameObject, selection);

            object sceneHierarchy = NSelection.SceneHierarchy;

            int[] expandedState = NSelection.GetHierarchyExpandedState();
            // Persist the selection in the state.
            foreach (int i in expandedState)
            {
                Object o = NSelection.HierarchyIdToObject(i, sceneHierarchy);
                if (!selection.Contains(o))
                {
                    continue;
                }
                if (!newState.Contains(i))
                {
                    newState.Add(i);
                }
            }

            // If unsorted, the hierarchy will break.
            newState.Sort();

            NSelection.SetHierarchyToState(newState);
        }
 private static void SetHierarchyExpandedState() => _allExpandedIDs = NSelection.GetHierarchyExpandedState();