示例#1
0
        public override void SavePref()
        {
            EditorPrefs.SetBool(FormKey("enabled"), this.enabled);

            // Bar
            {
                EditorPrefs.SetBool(FormKey("colorizedLine"), this.colorizedLine);
                EditorPrefs.SetFloat(FormKey("lineAlpha"), this.lineAlpha);
                EditorPrefs.SetFloat(FormKey("lineWidth"), this.lineWidth);
            }

            // Item
            {
                EditorPrefs.SetBool(FormKey("colorizedItem"), this.colorizedItem);
                EditorPrefs.SetInt(FormKey("drawMode"), (int)this.drawMode);
                EditorPrefs.SetFloat(FormKey("gradientLength"), this.gradientLength);
                HierarchyUtil.SetColor(FormKey("baseLevelColor"), this.baseLevelColor);
                {
                    this.branchesLen = this.branches.Length;
                    EditorPrefs.SetInt(FormKey("branches.Length"), this.branchesLen);

                    for (int index = 0; index < branches.Length; ++index)
                    {
                        HierarchyUtil.SetColor(FormKey("branches" + index), instance.branches[index]);
                    }
                }
                EditorPrefs.SetFloat(FormKey("overlayAlpha"), this.overlayAlpha);
            }

            // Divider
            {
                HierarchyUtil.SetColor(FormKey("dividerColor"), this.dividerColor);
                EditorPrefs.SetFloat(FormKey("dividerHeight"), this.dividerHeight);
            }
        }
示例#2
0
 public override void SavePref()
 {
     EditorPrefs.SetBool(FormKey("enabled"), this.enabled);
     EditorPrefs.SetString(FormKey("prefix"), this.prefix);
     HierarchyUtil.SetColor(FormKey("color"), this.color);
     EditorPrefs.SetBool(FormKey("drawFill"), this.drawFill);
 }
示例#3
0
        public override void Draw()
        {
            foldout = EditorGUILayout.Foldout(foldout, FOLD_NAME);

            if (!foldout)
            {
                return;
            }

            HierarchyUtil.CreateGroup(() =>
            {
                HierarchyUtil.CreateInfo(INFO);

                this.enabled = HierarchyUtil.Toggle("Enabeld", this.enabled,
                                                    @"Enable/Disable all features from this section");

                HierarchyUtil.LabelField("Hide Flags");

                HierarchyUtil.CreateGroup(() =>
                {
                    HierarchyUtil.CreateInfo(@"Hide specific log level");

                    this.hideLog = HierarchyUtil.Toggle("Hide Log", this.hideLog,
                                                        @"Hide log");
                    this.hideWarning = HierarchyUtil.Toggle("Hide Warning", this.hideWarning,
                                                            @"Hide warning");
                    this.hideError = HierarchyUtil.Toggle("Hide Error", this.hideError,
                                                          @"Hide error");
                });
            });
        }
示例#4
0
        private static void OnClick_Component(int instanceID, Type t)
        {
            bool selected = Selection.activeGameObject == currentGO;

            Selection.activeGameObject = currentGO;

            if (!selected)
            {
                return;
            }

            var check     = currentItem.components[0];
            var checkType = check.GetType();

            if (checkType == t && currentItem.components.Count > 1)
            {
                checkType = currentItem.components[1].GetType();
            }

            bool otherExpanded = HierarchyUtil.IsExpanded(instanceID, checkType);
            bool selfExpanded  = HierarchyUtil.IsExpanded(instanceID, t);

            if (!selfExpanded || !selected)
            {
                HierarchyUtil.FocusComponent(instanceID, t);
            }
            else if (!otherExpanded)
            {
                HierarchyUtil.ExpandComponents(instanceID, true);
            }
            else
            {
                HierarchyUtil.FocusComponent(instanceID, t);
            }
        }
示例#5
0
        public override void Draw()
        {
            foldout = EditorGUILayout.Foldout(foldout, FOLD_NAME);

            if (!foldout)
            {
                return;
            }

            HierarchyUtil.CreateGroup(() =>
            {
                HierarchyUtil.CreateInfo(INFO);

                this.enabled = HierarchyUtil.Toggle("Enabeld", this.enabled,
                                                    @"Enable/Disable all features from this section");

                HierarchyUtil.BeginHorizontal(() =>
                {
                    this.color = HierarchyUtil.ColorField("Color", this.color,
                                                          @"Color for odd row");
                    HierarchyUtil.Button("Reset", ResetColor);
                });

                this.drawFill = HierarchyUtil.Toggle("Draw Fill", this.drawFill,
                                                     @"Draw the row entirely to the left");
            });
        }
示例#6
0
        public override void Draw()
        {
            foldout = EditorGUILayout.Foldout(foldout, FOLD_NAME);

            if (!foldout)
            {
                return;
            }

            HierarchyUtil.CreateGroup(() =>
            {
                HierarchyUtil.CreateInfo(INFO);

                this.enabled = HierarchyUtil.Toggle("Enabeld", this.enabled,
                                                    @"Enable/Disable all features from this section");

                this.focus = HierarchyUtil.Toggle("Folding", this.focus,
                                                  @"Focus the component after clicking the icon");

                HierarchyUtil.BeginHorizontal(() =>
                {
                    this.disableAlpa = HierarchyUtil.Slider("Disable Alpha", this.disableAlpa, 0.1f, 0.9f,
                                                            @"Alpha for disabled components");
                    HierarchyUtil.Button("Reset", ResetDisableAlpha);
                });
            });
        }
示例#7
0
 public override void Init()
 {
     this.enabled  = EditorPrefs.GetBool(FormKey("enabled"), this.enabled);
     this.prefix   = EditorPrefs.GetString(FormKey("prefix"), this.prefix);
     this.color    = HierarchyUtil.GetColor(FormKey("color"), this.color);
     this.drawFill = EditorPrefs.GetBool(FormKey("drawFill"), this.drawFill);
 }
示例#8
0
        public override void Draw()
        {
            foldout = EditorGUILayout.Foldout(foldout, FOLD_NAME);

            if (!foldout)
            {
                return;
            }

            HierarchyUtil.CreateGroup(() =>
            {
                HierarchyUtil.CreateInfo(INFO);

                this.enabled = HierarchyUtil.Toggle("Enabeld", this.enabled,
                                                    @"Enable/Disable all features from this section");

                HierarchyUtil.BeginHorizontal(() =>
                {
                    this.prefix = HierarchyUtil.TextField("Prefix", this.prefix,
                                                          @"Prefix string for separator in GameObject's name");
                    HierarchyUtil.Button("Reset", ResetPrefix);
                });

                HierarchyUtil.BeginHorizontal(() =>
                {
                    this.color = HierarchyUtil.ColorField("Color", this.color,
                                                          @"Color of the separator");
                    HierarchyUtil.Button("Reset", ResetColor);
                });

                this.drawFill = HierarchyUtil.Toggle("Draw Fill", this.drawFill,
                                                     @"Draw separator from start all the way to the end");
            });
        }
示例#9
0
        public override void Init()
        {
            this.enabled = EditorPrefs.GetBool(FormKey("enabled"), this.enabled);
            // Bar
            {
                this.colorizedLine = EditorPrefs.GetBool(FormKey("colorizedLine"), this.colorizedLine);
                this.lineAlpha     = EditorPrefs.GetFloat(FormKey("lineAlpha"), this.lineAlpha);
                this.lineWidth     = EditorPrefs.GetFloat(FormKey("lineWidth"), this.lineWidth);
            }
            // Item
            {
                this.colorizedItem  = EditorPrefs.GetBool(FormKey("colorizedItem"), this.colorizedItem);
                this.drawMode       = (DrawMode)EditorPrefs.GetInt(FormKey("drawMode"), (int)this.drawMode);
                this.gradientLength = EditorPrefs.GetFloat(FormKey("gradientLength"), this.gradientLength);
                this.baseLevelColor = HierarchyUtil.GetColor(FormKey("baseLevelColor"), this.baseLevelColor);
                this.branchesLen    = EditorPrefs.GetInt(FormKey("branches.Length"), this.branchesLen);
                this.overlayAlpha   = EditorPrefs.GetFloat(FormKey("overlayAlpha"), this.overlayAlpha);
            }
            // Divider
            {
                this.dividerColor  = HierarchyUtil.GetColor(FormKey("dividerColor"), this.dividerColor);
                this.dividerHeight = EditorPrefs.GetFloat(FormKey("dividerHeight"), this.dividerHeight);
            }

            DynamicRefresh();
        }
示例#10
0
        public override void Init()
        {
            {
                this.enabled = false;
            }

            this.enabled = EditorPrefs.GetBool(FormKey("enabled"), this.enabled);
            this.color   = HierarchyUtil.GetColor(FormKey("color"), this.color);
        }
示例#11
0
        private static void DrawCore(int instanceID, Rect selectionRect)
        {
            // skips early if item is not registered or not valid
            if (!sceneGameObjects.ContainsKey(instanceID))
            {
                return;
            }

            currentGO = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
            if (currentGO == null)
            {
                return;
            }

            currentItem = sceneGameObjects[instanceID];

            /* Initialzie draw variables */
            {
                bool alphaSorted = HierarchyWindowAdapter.IsUsingAlphaSort();
                if (ALPHA_SORTED != alphaSorted)
                {
                    ALPHA_SORTED = alphaSorted;

                    // This is bad since we retrieve data twice when the user
                    // changes their hierarchy sorting type.
                    //
                    // Yet this may be okay since the user doesn't change
                    // the sorting type that often.
                    RetrieveDataFromHierarchy();
                }

                ROW_HEIGHT     = GUI.skin.label.lineHeight + 1; // default is 16 pixels
                MAX_TAG_LEN    = HierarchyUtil.MaxLabelLength(tags.ToArray(), (data.tag.GetEnabled() && data.tag.enabledText));
                MAX_LAYER_LEN  = HierarchyUtil.MaxLabelLength(layers.ToArray(), (data.layer.GetEnabled() && data.layer.enabledText));
                MAX_INSTID_LEN = HierarchyUtil.MaxIntLength(instanceIDs.ToArray(), data.instanceID.GetEnabled());

                RIGHT_BOUNDARY = 0.0f;  // reset
                if (EXISTS_PREFAB_ICON)
                {
                    RIGHT_BOUNDARY += ROW_HEIGHT;
                }
            }

            //-- Full
            DrawAlternatingBG(instanceID, selectionRect);
            DrawTree(instanceID, selectionRect);
            DrawSeparators(instanceID, selectionRect);
            //-- Left
            DrawIcons(instanceID, selectionRect);
            DrawLog(instanceID, selectionRect);
            //-- Right
            DrawComponents(instanceID, selectionRect);
            DrawTag(instanceID, selectionRect);
            DrawLayer(instanceID, selectionRect);
            DrawInstanceID(instanceID, selectionRect);
        }
示例#12
0
 private void DynamicRefresh()
 {
     if (branchesLen > 0)
     {
         instance.branches = new Color[branchesLen];
         for (int index = 0; index < branchesLen; ++index)
         {
             instance.branches[index] = HierarchyUtil.GetColor(FormKey("branches" + index), instance.branches[index]);
         }
     }
 }
示例#13
0
        private static void DrawIcons(int instanceID, Rect selectionRect)
        {
            if (!data.icons.GetEnabled())
            {
                return;
            }

            bool defaultIcon = false;

            // Draws the gameobject icon, if present
            var content = EditorGUIUtility.ObjectContent(currentGO, null);
            var image   = content.image;

            bool validImage = (image && !string.IsNullOrEmpty(image.name));

            if (validImage)
            {
                defaultIcon = (image.name == "d_GameObject Icon");

                HierarchyWindowAdapter.ApplyIconByInstanceId(instanceID, content.image);
            }
            else
            {
                HierarchyWindowAdapter.ApplyIconByInstanceId(instanceID, HierarchyUtil.BrokenIcon());
            }

            if (defaultIcon && data.icons.guess)
            {
                foreach (var comp in currentItem.components)
                {
                    if (comp == null)
                    {
                        continue;
                    }

                    var t        = comp.GetType();
                    var typeName = t.ToString();

                    {
                        var lst = typeName.Split('.');
                        typeName = lst[lst.Length - 1];
                    }

                    if (HierarchyUtil.ContainString(typeName, currentItem.goName))
                    {
                        var compImage = HierarchyUtil.TypeTexture(comp, t);
                        HierarchyWindowAdapter.ApplyIconByInstanceId(instanceID, compImage);
                        currentItem.guessedComponent = comp;
                        break;
                    }
                }
            }
        }
示例#14
0
 /// <summary>
 /// Draw component texture with flag `enabled`.
 /// </summary>
 private static void DrawEnableComponentTexture(Type t, Rect rect, Texture image, bool enabled)
 {
     // If we are drawing behbaviour, we draw with alpha channel weather
     // the component is enabled.
     if (enabled)
     {
         HierarchyUtil.DrawTextureTooltip(rect, image, t.Name);
     }
     else
     {
         HierarchyUtil.DrawTextureTooltip(rect, image, t.Name, data.components.disableAlpa);
     }
 }
示例#15
0
        public override void Draw()
        {
            const float spaces = 200;

            this.enabled = HierarchyUtil.Toggle("Enabeld", this.enabled,
                                                @"Enable the plugin sHierarchy", spaces);
            this.updateInPlayMode = HierarchyUtil.Toggle("Update in Play Mode", this.updateInPlayMode,
                                                         @"Draw in Play Mode", spaces);
            this.updateInPrefabIsoMode = HierarchyUtil.Toggle("Update in Prefab Mode", this.updateInPrefabIsoMode,
                                                              @"Draw in Prefab Isolation Mode", spaces);

            ExecuteAll(HierarchyComponentFunctions.DRAW);
        }
示例#16
0
        public override void Init()
        {
            this.enabled = EditorPrefs.GetBool(FormKey("enabled"), this.enabled);

            this.enabledText       = EditorPrefs.GetBool(FormKey("enabledText"), this.enabledText);
            this.textColorUntagged = HierarchyUtil.GetColor(FormKey("textColorUntagged"), this.textColorUntagged);
            this.textColor         = HierarchyUtil.GetColor(FormKey("textColor"), this.textColor);

            this.enabledItem     = EditorPrefs.GetBool(FormKey("enabledItem"), this.enabledItem);
            this.itemColors      = HierarchyUtil.GetDictionary(FormKey("itemColors"), this.itemColors);
            this.gradientLength  = HierarchyUtil.GetData(FormKey("gradientLength"), this.gradientLength);
            this.invertDirection = HierarchyUtil.GetData(FormKey("invertDirection"), this.invertDirection);
        }
示例#17
0
        public override void SavePref()
        {
            EditorPrefs.SetBool(FormKey("enabled"), this.enabled);

            EditorPrefs.SetBool(FormKey("enabledText"), this.enabledText);
            HierarchyUtil.SetColor(FormKey("textColorUntagged"), this.textColorUntagged);
            HierarchyUtil.SetColor(FormKey("textColor"), this.textColor);

            EditorPrefs.SetBool(FormKey("enabledItem"), this.enabledItem);
            HierarchyUtil.SetDictionary(FormKey("itemColors"), this.itemColors);
            HierarchyUtil.SetData(FormKey("gradientLength"), this.gradientLength);
            HierarchyUtil.SetData(FormKey("invertDirection"), this.invertDirection);
        }
示例#18
0
        private static void Draw()
        {
            GUILayout.Space(10);

            HierarchyUtil.BeginHorizontal(() =>
            {
                GUILayout.Space(10);

                HierarchyUtil.BeginVertical(() =>
                {
                    data.Draw();
                }, "");
            });
        }
示例#19
0
        public override void Init()
        {
            // Here emphasize we want this to be disabled by default!
            {
                this.enabled = false;
            }

            this.enabled = EditorPrefs.GetBool(FormKey("enabled"), this.enabled);

            this.enabledText      = EditorPrefs.GetBool(FormKey("enabledText"), this.enabledText);
            this.textColorDefault = HierarchyUtil.GetColor(FormKey("textColorDefault"), this.textColorDefault);
            this.textColor        = HierarchyUtil.GetColor(FormKey("textColor"), this.textColor);

            this.enabledItem     = EditorPrefs.GetBool(FormKey("enabledItem"), this.enabledItem);
            this.itemColors      = HierarchyUtil.GetDictionary(FormKey("itemColors"), this.itemColors);
            this.gradientLength  = HierarchyUtil.GetData(FormKey("gradientLength"), this.gradientLength);
            this.invertDirection = HierarchyUtil.GetData(FormKey("invertDirection"), this.invertDirection);
        }
示例#20
0
        private static void DrawComponents(int instanceID, Rect selectionRect)
        {
            if (!data.components.GetEnabled())
            {
                return;
            }

            temp_iconsDrawedCount = 0;
            float offsetX_const = 3;
            float offsetX       = RIGHT_BOUNDARY + offsetX_const + MAX_TAG_LEN + MAX_LAYER_LEN + MAX_INSTID_LEN;

            bool omitComp    = data.icons.omitComp;
            bool guessedComp = (currentItem.guessedComponent != null);

            foreach (Component comp in currentItem.components)
            {
                if (omitComp && guessedComp && comp == currentItem.guessedComponent)
                {
                    continue;
                }

                // When component is null, meaning there is broken link
                // so here we accept null value.
                var t     = (comp == null) ? null : comp.GetType();
                var image = HierarchyUtil.TypeTexture(comp, t);

                float offset = offsetX + (ROW_HEIGHT * temp_iconsDrawedCount);
                float x      = selectionRect.xMax - offset;
                Rect  rect   = new Rect(x, selectionRect.yMin, ROW_HEIGHT, ROW_HEIGHT);

                HierarchyRenderer.DrawComponent(t, currentGO, rect, image);

                if (data.components.focus && GUI.Button(rect, "", "Label"))
                {
                    OnClick_Component(instanceID, t);
                }

                ++temp_iconsDrawedCount;
            }
        }
        /* Setter & Getter */

        /* Functions */

        public override void OnInspectorGUI()
        {
            HierarchyUtil.CreateInfo(INFO);

            this.mTarget = (HierarchyControlPanel)this.target;

            EditorGUI.BeginChangeCheck();

            DrawOption(HierarchyData.f_alterRowShading, ref mTarget.f_alterRowShading,
                       "Alternate Row Shading", @"Enable feature Alternate Row Shading");

            DrawOption(HierarchyData.f_separator, ref mTarget.f_separator,
                       "Separator", @"Enable feature Separator");

            DrawOption(HierarchyData.f_tree, ref mTarget.f_tree,
                       "Tree", @"Enable feature Tree");

            DrawOption(HierarchyData.f_log, ref mTarget.f_log,
                       "Logs", @"Enable feature Logs");

            DrawOption(HierarchyData.f_icons, ref mTarget.f_icons,
                       "Icons", @"Enable feature Icons");

            DrawOption(HierarchyData.f_components, ref mTarget.f_components,
                       "Components", @"Enable feature Components");

            DrawOption(HierarchyData.f_tag, ref mTarget.f_tag,
                       "Tag", @"Enable feature Tag");

            DrawOption(HierarchyData.f_layer, ref mTarget.f_layer,
                       "Layer", @"Enable feature Layer");

            DrawOption(HierarchyData.f_instanceID, ref mTarget.f_instanceID,
                       "Instance ID", @"Enable feature Instance ID");

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(mTarget);
            }
        }
示例#22
0
        public static bool DrawLogIcon(GameObject go, Rect selectionRect, Dictionary <string, string> log, LogType type, int iconLevel)
        {
            if (type == LogType.Log && data.log.hideLog)
            {
                return(false);
            }
            if (type == LogType.Warning && data.log.hideWarning)
            {
                return(false);
            }
            if (type == LogType.Error && data.log.hideError)
            {
                return(false);
            }

            foreach (KeyValuePair <string, string> entry in log)
            {
                string t = entry.Key;

                Component component = go.GetComponent(t);
                if (component == null)
                {
                    continue;
                }

                var stackTrace = entry.Value;
                var c          = GetLogIcon(type, stackTrace);

                var x = GetNameX(selectionRect, currentItem.nestingLevel) + (ROW_HEIGHT * iconLevel);

                Rect rect = new Rect(x, selectionRect.yMin, ROW_HEIGHT, ROW_HEIGHT);

                HierarchyUtil.DrawTextureTooltip(rect, c.image, stackTrace);

                return(true);
            }

            return(false);
        }
示例#23
0
        public override void Draw()
        {
            foldout = EditorGUILayout.Foldout(foldout, FOLD_NAME);

            if (!foldout)
            {
                return;
            }

            HierarchyUtil.CreateGroup(() =>
            {
                HierarchyUtil.CreateInfo(INFO);

                this.enabled = HierarchyUtil.Toggle("Enabeld", this.enabled,
                                                    @"Enable/Disable all features from this section");

                this.guess = HierarchyUtil.Toggle("Guess", this.guess,
                                                  @"Guess the icon by the name of the GameObject");

                this.omitComp = HierarchyUtil.Toggle("Omit Component", this.omitComp,
                                                     @"Omit guessed component");
            });
        }
示例#24
0
        public static void DrawComponent(Type t, GameObject go, Rect rect, Texture image)
        {
            if (t == null)
            {
                HierarchyUtil.DrawTextureTooltip(rect, image, "Missing component");
                return;
            }

            if (t.IsSubclassOf(typeof(Behaviour)))
            {
                var comp = go.GetComponent(t) as Behaviour;
                if (comp != null)
                {
                    DrawEnableComponentTexture(t, rect, image, comp.enabled);
                }
            }
            else if (t.IsSubclassOf(typeof(Collider)))
            {
                var comp = go.GetComponent(t) as Collider;
                if (comp != null)
                {
                    DrawEnableComponentTexture(t, rect, image, comp.enabled);
                }
            }
            else if (t.IsSubclassOf(typeof(Renderer)))
            {
                var comp = go.GetComponent(t) as Renderer;
                if (comp != null)
                {
                    DrawEnableComponentTexture(t, rect, image, comp.enabled);
                }
            }
            else
            {
                HierarchyUtil.DrawTextureTooltip(rect, image, t.Name);
            }
        }
示例#25
0
 public override string FormKey(string name)
 {
     return(HierarchyUtil.FormKey("separator.") + name);
 }
示例#26
0
 public override string FormKey(string name)
 {
     return(HierarchyUtil.FormKey("instanceID.") + name);
 }
示例#27
0
 public override void SavePref()
 {
     EditorPrefs.SetBool(FormKey("enabled"), this.enabled);
     HierarchyUtil.SetColor(FormKey("color"), this.color);
 }
示例#28
0
        public override void Draw()
        {
            foldout = EditorGUILayout.Foldout(foldout, FOLD_NAME);

            if (!foldout)
            {
                return;
            }

            HierarchyUtil.CreateGroup(() =>
            {
                HierarchyUtil.CreateInfo(INFO);

                this.enabled = HierarchyUtil.Toggle("Enabeld", this.enabled,
                                                    @"Enable/Disable all features from this section");

                HierarchyUtil.LabelField("Bar");

                HierarchyUtil.CreateGroup(() =>
                {
                    HierarchyUtil.CreateInfo("Colorized Bar by tree level");

                    this.colorizedLine = HierarchyUtil.Toggle("Colorized Line", this.colorizedLine,
                                                              @"Enabled/Disabled to colorized bar");

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        this.lineAlpha = HierarchyUtil.Slider("Line Alpha", this.lineAlpha, 0.0f, 1.0f,
                                                              @"Alpha level for the bar");
                        HierarchyUtil.Button("Reset", ResetLineAlpha);
                    });

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        this.lineWidth = HierarchyUtil.Slider("Line Width", this.lineWidth, 0.001f, 3.0f,
                                                              @"Line width for the bar");
                        HierarchyUtil.Button("Reset", ResetLineWidth);
                    });
                });

                HierarchyUtil.LabelField("Item");

                HierarchyUtil.CreateGroup(() =>
                {
                    HierarchyUtil.CreateInfo("Colorized Item by tree level");

                    this.colorizedItem = HierarchyUtil.Toggle("Colorized Item", this.colorizedItem,
                                                              @"Enabled/Disabled to colorized item");

                    this.drawMode = (DrawMode)HierarchyUtil.EnumPopup("Draw Mode", this.drawMode,
                                                                      @"Mode for item to draw");

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        this.gradientLength = HierarchyUtil.Slider("Gradient Length", this.gradientLength, 0.01f, 1.0f,
                                                                   @"Time of the gradient faded to alpha 0");
                        HierarchyUtil.Button("Reset", ResetGradientLength);
                    });

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        this.overlayAlpha = HierarchyUtil.Slider("Overlay Alpha", this.overlayAlpha, 0.0f, 0.8f,
                                                                 @"Alpha level for the item");
                        HierarchyUtil.Button("Reset", ResetOverlayAlpha);
                    });

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        this.baseLevelColor = HierarchyUtil.ColorField("Base Level Color", this.baseLevelColor,
                                                                       @"Base color for colorized item");
                        HierarchyUtil.Button("Reset", ResetBaseLevelColor);
                    });

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        instance         = ScriptableObject.CreateInstance <Container_TreeData>();
                        serializedObject = new SerializedObject(instance);
                        propBranches     = serializedObject.FindProperty("branches");

                        DynamicRefresh();

                        serializedObject.Update();
                        EditorGUILayout.PropertyField(propBranches);
                        serializedObject.ApplyModifiedProperties();

                        HierarchyUtil.Button("Reset", ResetBranchesColor);
                    });
                });

                HierarchyUtil.LabelField("Divider");

                HierarchyUtil.CreateGroup(() =>
                {
                    HierarchyUtil.CreateInfo("Thin lines indicate each group of tree level");

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        this.dividerColor = HierarchyUtil.ColorField("Color", this.dividerColor,
                                                                     @"Color for the divider");
                        HierarchyUtil.Button("Reset", ResetDividerColor);
                    });

                    HierarchyUtil.BeginHorizontal(() =>
                    {
                        this.dividerHeight = HierarchyUtil.Slider("Divider Height", this.dividerHeight, 0.0f, 3.0f,
                                                                  @"Height of the divider");
                        HierarchyUtil.Button("Reset", ResetDividerHeight);
                    });
                });
            });
        }
示例#29
0
 public override string FormKey(string name)
 {
     return(HierarchyUtil.FormKey("tree.") + name);
 }
示例#30
0
        static void AnalyzeGoWithChildren(GameObject go, int nestingLevel, bool topParentHasChild, int nestingGroup, bool isLastChild)
        {
            int instanceID = go.GetInstanceID();

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

                // We minus 1 when inside prefab isolation mode only when
                // in the first level of Prefab Isolation Mode.
                if (!IsMainStage() && currentPrefab && currentPrefab.transform.parent == null)
                {
                    --newInfo.nestingLevel;
                }

                tags.Add(go.tag);
                layers.Add(LayerMask.LayerToName(go.layer));
                instanceIDs.Add(instanceID);

                /* Prefab Data */
                {
                    var prefab = PrefabUtility.GetCorrespondingObjectFromSource(go);
                    if (prefab)
                    {
                        newInfo.prefabInstanceID = prefab.GetInstanceID();
                        EXISTS_PREFAB_ICON       = true;
                    }
                }

                if (data.separator.GetEnabled())
                {
                    newInfo.isSeparator = String.Compare(go.tag, "EditorOnly", StringComparison.Ordinal) == 0 && // gameobject has EditorOnly tag
                                          (!string.IsNullOrEmpty(go.name) && !string.IsNullOrEmpty(data.separator.prefix) &&
                                           go.name.StartsWith(data.separator.prefix));    // and also starts with '>'
                }

                if (data.icons.GetEnabled() || data.components.GetEnabled())
                {
                    #region Components Information (icons)

                    var comps = go.GetComponents <Component>();

                    foreach (var c in comps)
                    {
                        if (c == null)
                        {
                            newInfo.components.Add(null);  // missing
                            continue;
                        }
                        newInfo.components.Add(c);
                    }

                    #endregion
                }

                //Adds element to the array
                sceneGameObjects.Add(instanceID, newInfo);
            }

            #region Analyzes Childrens

            int          childCount = go.transform.childCount;
            GameObject[] childrens  = HierarchyUtil.GetAllChilds(go);

            if (ALPHA_SORTED)
            {
                childrens = childrens.OrderBy(tmpGo => go.name).ToArray();
            }

            for (int j = 0; j < childCount; ++j)
            {
                var child = childrens[j];

                AnalyzeGoWithChildren(
                    child,
                    nestingLevel + 1,
                    topParentHasChild,
                    nestingGroup,
                    j == childCount - 1);
            }

            #endregion
        }