private void DoIconAndName(Rect rect, AnimationWindowHierarchyNode node, bool selected, bool focused, float indent)
        {
            EditorGUIUtility.SetIconSize(new Vector2(13, 13));   // If not set we see icons scaling down if text is being cropped

            // TODO: All this is horrible. SHAME FIX!
            if (Event.current.type == EventType.Repaint)
            {
                if (selected)
                {
                    selectionStyle.Draw(rect, false, false, true, focused);
                }

                // Leave some space for the value field that comes after.
                if (node is AnimationWindowHierarchyPropertyNode)
                {
                    rect.width -= k_ValueFieldOffsetFromRightSide + 2;
                }

                bool isLeftOverCurve = AnimationWindowUtility.IsNodeLeftOverCurve(node);
                bool isAmbiguous     = AnimationWindowUtility.IsNodeAmbiguous(node);
                bool isPhantom       = AnimationWindowUtility.IsNodePhantom(node);

                string warningText = "";
                string tooltipText = "";
                if (isPhantom)
                {
                    warningText = " (Default Value)";
                    tooltipText = "Transform position, rotation and scale can't be partially animated. This value will be animated to the default value";
                }
                if (isLeftOverCurve)
                {
                    warningText = " (Missing!)";
                    tooltipText = "The GameObject or Component is missing (" + node.path + ")";
                }
                if (isAmbiguous)
                {
                    warningText = " (Duplicate GameObject name!)";
                    tooltipText = "Target for curve is ambiguous since there are multiple GameObjects with same name (" + node.path + ")";
                }

                Color oldColor  = lineStyle.normal.textColor;
                Color textColor = oldColor;
                if (node.depth == 0)
                {
                    string nodePrefix = "";
                    if (node.curves.Length > 0)
                    {
                        AnimationWindowSelectionItem selectionBinding = node.curves[0].selectionBinding;
                        string gameObjectName = GetGameObjectName(selectionBinding != null ? selectionBinding.rootGameObject : null, node.path);
                        nodePrefix = string.IsNullOrEmpty(gameObjectName) ? "" : gameObjectName + " : ";
                    }

                    Styles.content = new GUIContent(nodePrefix + node.displayName + warningText, GetIconForItem(node), tooltipText);

                    textColor = EditorGUIUtility.isProSkin ? Color.gray * 1.35f : Color.black;
                }
                else
                {
                    Styles.content = new GUIContent(node.displayName + warningText, GetIconForItem(node), tooltipText);

                    textColor = EditorGUIUtility.isProSkin ? Color.gray : m_LightSkinPropertyTextColor;

                    var phantomColor = selected ? m_PhantomCurveColor * k_SelectedPhantomCurveColorMultiplier : m_PhantomCurveColor;
                    textColor = isPhantom ? phantomColor : textColor;
                }
                textColor = isLeftOverCurve || isAmbiguous ? k_LeftoverCurveColor : textColor;
                SetStyleTextColor(lineStyle, textColor);

                rect.xMin += (int)(indent + foldoutStyleWidth + lineStyle.margin.left);
                GUI.Label(rect, Styles.content, lineStyle);

                SetStyleTextColor(lineStyle, oldColor);
            }

            if (IsRenaming(node.id) && Event.current.type != EventType.Layout)
            {
                GetRenameOverlay().editFieldRect = new Rect(rect.x + k_IndentWidth, rect.y, rect.width - k_IndentWidth - 1, rect.height);
            }
        }
Beispiel #2
0
 private void DoIconAndName(Rect rect, AnimationWindowHierarchyNode node, bool selected, bool focused, float indent)
 {
     EditorGUIUtility.SetIconSize(new Vector2(13f, 13f));
     if (Event.current.type == EventType.Repaint)
     {
         if (selected)
         {
             TreeViewGUI.Styles.selectionStyle.Draw(rect, false, false, true, focused);
         }
         if (node is AnimationWindowHierarchyPropertyNode)
         {
             rect.width -= 77f;
         }
         bool   flag    = AnimationWindowUtility.IsNodeLeftOverCurve(node);
         bool   flag2   = AnimationWindowUtility.IsNodeAmbiguous(node);
         bool   flag3   = AnimationWindowUtility.IsNodePhantom(node);
         string text    = "";
         string tooltip = "";
         if (flag3)
         {
             text    = " (Default Value)";
             tooltip = "Transform position, rotation and scale can't be partially animated. This value will be animated to the default value";
         }
         if (flag)
         {
             text    = " (Missing!)";
             tooltip = "The GameObject or Component is missing (" + node.path + ")";
         }
         if (flag2)
         {
             text    = " (Duplicate GameObject name!)";
             tooltip = "Target for curve is ambiguous since there are multiple GameObjects with same name (" + node.path + ")";
         }
         Color textColor = this.m_AnimationLineStyle.normal.textColor;
         Color color;
         if (node.depth == 0)
         {
             string str = "";
             if (node.curves.Length > 0)
             {
                 AnimationWindowSelectionItem selectionBinding = node.curves[0].selectionBinding;
                 if (selectionBinding != null)
                 {
                     if (selectionBinding.rootGameObject != null)
                     {
                         Transform x = selectionBinding.rootGameObject.transform.Find(node.path);
                         if (x == null)
                         {
                             flag = true;
                         }
                     }
                 }
                 string gameObjectName = this.GetGameObjectName((!(selectionBinding != null)) ? null : selectionBinding.rootGameObject, node.path);
                 str = ((!string.IsNullOrEmpty(gameObjectName)) ? (gameObjectName + " : ") : "");
             }
             TreeViewGUI.Styles.content = new GUIContent(str + node.displayName + text, this.GetIconForItem(node), tooltip);
             color = ((!EditorGUIUtility.isProSkin) ? Color.black : (Color.gray * 1.35f));
         }
         else
         {
             TreeViewGUI.Styles.content = new GUIContent(node.displayName + text, this.GetIconForItem(node), tooltip);
             color = ((!EditorGUIUtility.isProSkin) ? this.m_LightSkinPropertyTextColor : Color.gray);
             Color color2 = (!selected) ? this.m_PhantomCurveColor : (this.m_PhantomCurveColor * 1.4f);
             color = ((!flag3) ? color : color2);
         }
         color = ((!flag && !flag2) ? color : AnimationWindowHierarchyGUI.k_LeftoverCurveColor);
         this.SetStyleTextColor(this.m_AnimationLineStyle, color);
         rect.xMin += (float)((int)(indent + TreeViewGUI.Styles.foldoutWidth + (float)this.m_AnimationLineStyle.margin.left));
         GUI.Label(rect, TreeViewGUI.Styles.content, this.m_AnimationLineStyle);
         this.SetStyleTextColor(this.m_AnimationLineStyle, textColor);
     }
     if (this.IsRenaming(node.id) && Event.current.type != EventType.Layout)
     {
         base.GetRenameOverlay().editFieldRect = new Rect(rect.x + this.k_IndentWidth, rect.y, rect.width - this.k_IndentWidth - 1f, rect.height);
     }
 }