コード例 #1
0
    public static void DrawHelper(GameObject obj)
    {
        if (_checktip == null)
        {
            _checktip = new GUIContent(string.Empty, "Check Multi be Same");
            _multitip = new GUIContent(string.Empty, "Multi TreeTransform");
            _subtip   = new GUIContent(string.Empty, "Sub From TreeTransform");
            _addtip   = new GUIContent(string.Empty, "Add To TreeTransform");
        }
        Rect rect = HierarchyHelperManager.GetControlRect(8f);

        rect.y      += 3;
        rect.height -= 6;

        TreeTransform mine = obj.GetComponentInParent <TreeTransform>();
        int           num  = 0;

        if (mine == null)
        {
            return;
        }
        else if (mine.gameObject == obj)
        {
            num = mine.CheckMulti();
            HierarchyHelperTools.DrawWithColor(num == 2?Color.yellow:(num == 1?Color.red:Color.green), () =>
            {
                GUI.DrawTexture(rect, HierarchyHelperTools.WhiteTexture, ScaleMode.StretchToFill, true);
                GUI.Label(rect, _checktip);
            });
            return;
        }
        num = mine.CheckChild(obj.transform);
        Color color = num == 0 ? Color.white : (num == 1 ? Color.green : Color.red);

        if (GUI.Button(rect, "", "label"))
        {
            if (num == 0)
            {
                mine.AddChild(obj.transform);
            }
            else
            {
                mine.SubChild(obj.transform);
            }
        }
        HierarchyHelperTools.DrawWithColor(color, () => {
            GUI.Label(rect, num == 0 ? _addtip : (num == 1 ? _subtip : _multitip));
            rect.y      += 4;
            rect.height -= 8;
            GUI.DrawTexture(rect, HierarchyHelperTools.WhiteTexture, ScaleMode.StretchToFill, true);
            if (num == 0)
            {
                rect.y      -= 4;
                rect.x      += 3;
                rect.height += 8;
                rect.width  -= 6;
                GUI.DrawTexture(rect, HierarchyHelperTools.WhiteTexture, ScaleMode.StretchToFill, true);
            }
        });
    }
コード例 #2
0
    public static void DrawHelper(GameObject obj)
    {
        if (_yellowTooltip == null)
        {
            _yellowTooltip = new GUIContent(string.Empty, "Contains Missing Script(s) in Children");
            _redTooltip    = new GUIContent(string.Empty, "Contains Missing Script(s)");
            _greenTooltip  = new GUIContent(string.Empty);
        }

        Rect rect = HierarchyHelperManager.GetControlRect(4);

        rect.y      += 1;
        rect.height -= 2;

        Component[] allComponents   = obj.GetComponentsInChildren <Component>(true);
        bool        found           = false;
        bool        isMissingOnThis = false;

        foreach (Component allC in allComponents)
        {
            if (allC == null)
            {
                Component[] myComponents = obj.GetComponents <Component>( );
                foreach (Component myC in myComponents)
                {
                    if (myC == null)
                    {
                        isMissingOnThis = true;
                        break;
                    }
                }
                found = true;
                break;
            }
        }

        HierarchyHelperTools.DrawWithColor(found ? isMissingOnThis ? Color.red : Color.yellow : Color.green, () => {
            GUI.DrawTexture(rect, HierarchyHelperTools.WhiteTexture, ScaleMode.StretchToFill, true);
            GUI.Label(rect, found ? isMissingOnThis ? _redTooltip : _yellowTooltip : _greenTooltip);
        });
    }
コード例 #3
0
    public static void DrawLayerLock(GameObject obj)
    {
        bool locked = (Tools.lockedLayers & 1 << obj.layer) > 0;
        Rect rect   = HierarchyHelperManager.GetControlRect(16f);

        bool newLocked = locked;

        if (!locked)
        {
            HierarchyHelperTools.DrawWithColor(new Color(1f, 1f, 1f, 0.25f), () =>
                                               newLocked = GUI.Toggle(rect, locked, new GUIContent("", LayerMask.LayerToName(obj.layer)), "IN LockButton"));
        }
        else
        {
            newLocked = GUI.Toggle(rect, locked, new GUIContent("", LayerMask.LayerToName(obj.layer)), "IN LockButton");
        }

        if (newLocked != locked)
        {
            Tools.lockedLayers ^= 1 << obj.layer;
        }
    }