Пример #1
0
    private static void HandleHierarchyWindowItemOnGUI(int instanceID, Rect selectionRect)
    {
        var obj = EditorUtility.InstanceIDToObject(instanceID) as GameObject;

        if (obj != null)
        {
            HierarchyItemBoost itemBoost = obj.GetComponent <HierarchyItemBoost>();
            if (itemBoost != null)
            {
                Transform t = itemBoost.transform;
                if (t.position != Vector3.zero)
                {
                    t.position = Vector3.zero;
                }
                if (itemBoost.name != string.Empty)
                {
                    itemBoost.name = string.Empty;
                }
                if (t.localScale != Vector3.one)
                {
                    t.localScale = Vector3.one;
                }
                if (t.rotation != Quaternion.identity)
                {
                    t.rotation = Quaternion.identity;
                }

                DrawBoostItem(itemBoost, instanceID, ref selectionRect);
            }
            else
            {
                DrawNoneBoostItem(ref obj, instanceID, ref selectionRect);
                DrawPin(ref obj, instanceID, ref selectionRect);
            }

            DrawBothItem(ref obj, instanceID, ref selectionRect);
        }
    }
Пример #2
0
    private static void DrawBoostItem(HierarchyItemBoost itemBoost, int instanceID, ref Rect selectionRect)
    {
        Rect iconRect = new Rect(selectionRect.position + new Vector2(-2f, 0), new Vector2(selectionRect.size.y, selectionRect.size.y));
        Rect bgRect   = new Rect(selectionRect.position + new Vector2(selectionRect.size.y, 0), selectionRect.size + new Vector2(0, 1f));
        Rect bgRect2  = new Rect(selectionRect.position, selectionRect.size);
        Rect textRect = new Rect(bgRect.position + new Vector2(0, 1f), selectionRect.size);


        // Background
        EditorGUI.DrawRect(bgRect2, new Color(0.76f, 0.76f, 0.76f));
        GUIStyle style = null;

        switch (itemBoost.backgroundBoost)
        {
        case HierarchyBackgroundBoost.HELPBOX:
        {
            style = new GUIStyle(EditorStyles.helpBox);
            break;
        }

        case HierarchyBackgroundBoost.SOLID:
        {
            style = new GUIStyle();
            style.normal.background = EditorGUIUtility.whiteTexture;
            break;
        }

        case HierarchyBackgroundBoost.NONE:
        {
            style = new GUIStyle();
            break;
        }

        case HierarchyBackgroundBoost.TOOLBAR:
        {
            style = new GUIStyle(EditorStyles.toolbar);
            break;
        }

        case HierarchyBackgroundBoost.BUTTON:
        {
            style = new GUIStyle(EditorStyles.miniButton);
            break;
        }
        }

        var c = GUI.backgroundColor;

        GUI.backgroundColor = itemBoost.backgroundColor;
        GUI.Box(bgRect, "", style);
        GUI.backgroundColor = c;


        // Icon
        if (itemBoost.categoryBoost != HierarchyCategoryBoost.NONE)
        {
            GUIContent content = icons[HierarchyCategoryBoost.STANDARD];
            if (icons.ContainsKey(itemBoost.categoryBoost))
            {
                content = icons[itemBoost.categoryBoost];
            }
            GUI.Box(iconRect, content, new GUIStyle());
        }


        // Text Title
        GUIStyle styleText = new GUIStyle();

        styleText.normal = new GUIStyleState()
        {
            textColor = itemBoost.titleColor
        };
        styleText.fontStyle = FontStyle.Bold;
        EditorGUI.LabelField(textRect, " " + itemBoost.title + "", styleText);

        currentColor = itemBoost.backgroundColor;
        currentAlpha = itemBoost.backgroundChildAlpha;

        if (itemBoost.backgroundBoost == HierarchyBackgroundBoost.NONE)
        {
            GameObject obj = itemBoost.gameObject;
            DrawNoneBoostItem(ref obj, instanceID, ref selectionRect);
        }
    }