Ejemplo n.º 1
0
        private static void DrawSidebar(Rect position)
        {
            GUI.color = CurrentRowColor;

            float sideBarWidth = CalculateSideBarWidth();

            position.x     = position.width - sideBarWidth;
            position.width = sideBarWidth;

            GUI.DrawTexture(position, EditorGUIUtility.whiteTexture);
            GUI.color = Color.white;

            position.y    -= 1;
            position.width = kDividerWidth;

            GrendelGUI.ShadedGUILine(position, Color.gray, Color.white, Vector2.one);
        }
Ejemplo n.º 2
0
        internal static void DrawTreeBranch(GameObject gameObject, Rect position, int currentIndentAmount, int previousIndentAmount)
        {
            if (GrendelHierarchyView.CurrentParentCount <= 0 || gameObject == null)
            {
                return;
            }

            if (sTreeViewStyle == null)
            {
                SetupStyle();
            }

            position.x -= kTreeViewOffset;
            position.y -= 2;

            bool parentSelected = false;

            foreach (Transform parent in GrendelHierarchyView.CurrentParents)
            {
                if (GrendelSelection.SelectedGameObjects.Contains(parent.gameObject))
                {
                    parentSelected = true;
                }
            }

            Color currentTreeColour = parentSelected ? sTreeBranchSelectedColor: STreeBranchNormalColor;
            Color shadowColor       = sTreeBranchShadowColor;

            if (EditorApplication.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode)
            {
                currentTreeColour *= GrendelEditorGUIUtility.PlaymodeTintColor;
                shadowColor       *= GrendelEditorGUIUtility.PlaymodeTintColor;
            }

            GrendelGUI.ShadedLabel(position, kTreeItemTop, currentTreeColour, shadowColor, sTreeViewShadowOffset, sTreeViewStyle);

            if (previousIndentAmount <= currentIndentAmount && previousIndentAmount > 0 && !(sPreviousItemBranchRect.y > position.y))
            {
                if (gameObject.transform.GetSiblingIndex() == 0 && gameObject.transform.parent.GetSiblingIndex() + 1 == gameObject.transform.parent.parent.childCount)
                {
                    //do nothing
                }
                else
                {
                    Rect pos = new Rect(sPreviousItemBranchRect);
                    pos.y -= 1;
                    GrendelGUI.ShadedLabel(pos, kTreeItemBottom, currentTreeColour, shadowColor, sTreeViewShadowOffset, sTreeViewStyle);
                }
            }

            sPreviousItemBranchRect = new Rect(position);

            if (currentIndentAmount <= 1)
            {
                return;
            }

            float xPos = position.x;
            float yPos = position.y;

            for (int i = 1; i < currentIndentAmount; i++)
            {
                position.x = (xPos - (GrendelHierarchyView.kIndentWidth * i));
                position.y = yPos;

                Color outerBranchColor = STreeBranchNormalColor;

                if (EditorApplication.isPlayingOrWillChangePlaymode || EditorApplication.isPlaying)
                {
                    outerBranchColor *= GrendelEditorGUIUtility.PlaymodeTintColor;
                }

                if (GrendelHierarchyView.CurrentParents[i] != null)
                {
                    if ((i - 1 >= 0) && (GrendelHierarchyView.CurrentParents[i - 1].parent != null && (GrendelHierarchyView.CurrentParents[i - 1].GetSiblingIndex() + 1 < GrendelHierarchyView.CurrentParents[i - 1].parent.childCount)))
                    {
                        if (GrendelSelection.IsTransformAffectedBySelection(GrendelHierarchyView.CurrentParents[i - 1]))
                        {
                            outerBranchColor = sTreeBranchSelectedColor;
                        }

                        position.x += 1;

                        GrendelGUI.ShadedLabel(position, kTreeOuterBranch, outerBranchColor, shadowColor, sTreeViewShadowOffset, sTreeViewStyle);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void DrawPopup(GrendelLayerPreviewPopupState state)
        {
            if (state == null)
            {
                return;
            }

            Event currentEvent = Event.current;
            Rect  iconPosition = state.IconPosition;
            int   layer        = state.Object.gameObject.layer;

            float windowWidth = 128f;

            Rect layerRect;
            Rect checkmarkRect;
            Rect lastRect;
            Rect longLayerRect;

            int returnLayer = layer;

            //GenericMenu layerMenu = new GenericMenu();
            //GUIContent tempContent = new GUIContent(string.Empty);

            //for (int i = 0; i < sLayerNames.Length; i++)
            //{
            //    tempContent.text = sLayerNames[i];
            //    bool isOn = layer == i;
            //    layerMenu.AddItem(tempContent, isOn, SetLayer, i);
            //}


            //layerMenu.ShowAsContext();

            GUILayout.BeginVertical();

            for (int i = 0; i < sLayerNames.Length; i++)
            {
                GUILayout.BeginHorizontal(GUILayout.Height(kLayerEntryHeight));

                GUILayout.Label(layer == LayerMask.NameToLayer(sLayerNames[i]) ? kCheckMarkText : " ", GUILayout.Width(kLayerCheckMarkWidth), GUILayout.Height(kLayerEntryHeight));

                lastRect = checkmarkRect = GUILayoutUtility.GetLastRect();

                GrendelGUI.ShadedGUILine(new Rect(lastRect.x + kLayerCheckMarkWidth, lastRect.y - 4, 1, EditorGUIUtility.singleLineHeight + 1), Color.white, Color.gray, Vector2.one);

                layerRect           = GUILayoutUtility.GetRect(windowWidth - kLayerCheckMarkWidth, kLayerEntryHeight);
                longLayerRect       = new Rect(layerRect);
                longLayerRect.width = windowWidth;
                longLayerRect.x    -= kLayerCheckMarkWidth;

                GUI.color = GrendelLayerColours.GetLayerColor(LayerMask.NameToLayer(sLayerNames[i]));

                GUI.DrawTexture(layerRect, EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill);
                GUI.Label(layerRect, sLayerNames[i]);

                if (longLayerRect.Contains(currentEvent.mousePosition))
                {
                    GUI.color = Color.cyan;
                    GUI.Box(layerRect, string.Empty, sSelectionRectStyle);

                    if (LayerMask.NameToLayer(sLayerNames[i]) != layer)
                    {
                        GUI.color = Color.gray;
                        GUI.Label(checkmarkRect, kCheckMarkText, EditorStyles.whiteLabel);
                    }

                    if (currentEvent.type == EventType.MouseDown && currentEvent.button == 0)
                    {
                        returnLayer = LayerMask.NameToLayer(sLayerNames[i]);
                        currentEvent.Use();
                        state.IsExpanded = false;
                        sPopupWindow.Close();
                    }
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();

            GUI.color = Color.white;

            if (returnLayer != state.Object.TrueLayer)
            {
                state.Object.gameObject.layer = returnLayer; //TODO: Undo functionality
                EditorUtility.SetDirty(state.Object);
            }
        }