예제 #1
0
        private static void UpdateGameObjectsData(GameObject go, int nestingLevel, bool topParentHasChild, int nestingGroup, bool isLastChild, HierarchySeperator parentSeperator)
        {
            int instanceID = go.GetInstanceID();
            HierarchySeperator seperator = go.GetComponent <HierarchySeperator>();

            if (!sceneGameObjects.ContainsKey(instanceID)) //processes the gameobject only if it wasn't processed already
            {
                InstanceInfo newInfo = new InstanceInfo();
                newInfo.iconIndexes        = new List <int>();
                newInfo.isLastElement      = isLastChild && go.transform.childCount == 0;
                newInfo.nestingLevel       = nestingLevel;
                newInfo.nestingGroup       = nestingGroup;
                newInfo.hasChilds          = go.transform.childCount > 0;
                newInfo.isGameObjectActive = go.activeInHierarchy;
                newInfo.topParentHasChild  = topParentHasChild;

                newInfo.isGroupManager = seperator != null;
                if (seperator == null)
                {
                    seperator = parentSeperator;
                }
                newInfo.seperatorGroup = seperator;

                newInfo.isEditorOnly = string.Compare(go.tag, "EditorOnly", StringComparison.Ordinal) == 0;
                sceneGameObjects.Add(instanceID, newInfo);
            }

            int childCount = go.transform.childCount;

            for (int j = 0; j < childCount; j++)
            {
                UpdateGameObjectsData(go.transform.GetChild(j).gameObject, nestingLevel + 1, topParentHasChild, nestingGroup, j == childCount - 1, seperator);
            }
        }
예제 #2
0
        private static void DrawSeperatorGroupHeader(HierarchySeperator seperator, Rect rect)
        {
            if (seperator == null)
            {
                return;
            }

            GameObject go        = seperator.gameObject;
            Color      fontColor = Color.black;

            fontColor.a = (go.activeInHierarchy) ? 1 : seperatorGroupDisabledTransparency;
            Color backgroundColor = seperator.titleBackgroundColor;

            backgroundColor.a = (go.activeSelf) ? 1 : seperatorGroupDisabledTransparency;
            rect.height      -= 1;
            EditorGUI.DrawRect(rect, backgroundColor);

            var style = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.MiddleCenter,
                fontStyle = FontStyle.Bold,
                normal    = new GUIStyleState()
                {
                    textColor = fontColor
                }
            };

            EditorGUI.LabelField(rect, go.name.ToUpper(), style);

            //rect = new Rect(32, rect.y - Settings.dividerLineThickness / 2f, rect.width + (rect.x - 32), Settings.dividerLineThickness);
            //DrawDividerLine(rect, Color.black * 0.3f);
        }
        private static void CreateNewSeperator()
        {
            GameObject         go        = new GameObject("New Seperator");
            HierarchySeperator seperator = go.AddComponent <HierarchySeperator>();

            seperator.childBackgroundColor = HierarchySettings.Instance.seperatorGroupChildBackgroundColor;
            seperator.titleBackgroundColor = HierarchySettings.Instance.seperatorTitleBackgroundColor;

            Selection.objects = new GameObject[1] {
                go
            };
            Undo.RegisterCreatedObjectUndo(go, "Create seperator");
        }
예제 #4
0
        /// <summary>
        /// Updates the list of objects to draw, icons etc.
        /// </summary>
        static void RetrieveDataFromScene()
        {
            // Commented this for now as changing transform parent causes a lag spike during playmode
            if (/*!Settings.updateInPlayMode && */ Application.isPlaying)
            {
                return;
            }

            sceneGameObjects.Clear();
            iconsPositions.Clear();

            GameObject[] sceneRoots;
            Scene        tempScene;

            firstInstanceID = -1;

            for (int i = 0; i < SceneManager.sceneCount; i++)
            {
                tempScene = SceneManager.GetSceneAt(i);
                if (tempScene.isLoaded)
                {
                    sceneRoots = tempScene.GetRootGameObjects();
                    //Analyzes all scene's gameObjects
                    for (int j = 0; j < sceneRoots.Length; j++)
                    {
                        HierarchySeperator seperator = sceneRoots[j].GetComponent <HierarchySeperator>();
                        UpdateGameObjectsData(sceneRoots[j], 0, sceneRoots[j].transform.childCount > 0, j, j == sceneRoots.Length - 1, seperator);
                    }

                    if (firstInstanceID == -1 && sceneRoots.Length > 0)
                    {
                        firstInstanceID = sceneRoots[0].GetInstanceID();
                    }
                }
            }
        }