Пример #1
0
        private void DoAddCurveButton(Rect rowRect, TreeViewItem node)
        {
            // Is it propertynode. If not, then we don't need plusButton so quit here
            AddCurvesPopupPropertyNode hierarchyNode = node as AddCurvesPopupPropertyNode;

            if (hierarchyNode == null || hierarchyNode.curveBindings == null || hierarchyNode.curveBindings.Length == 0)
            {
                return;
            }

            Rect buttonRect = new Rect(rowRect.width - plusButtonWidth, rowRect.yMin, plusButtonWidth, buttonStyle.fixedHeight);

            // TODO Make a style for add curves popup
            // Draw background behind plus button to prevent text overlapping
            GUI.Box(buttonRect, GUIContent.none, plusButtonBackgroundStyle);

            // Check if the curve already exists and remove plus button
            if (GUI.Button(buttonRect, plusIcon, buttonStyle))
            {
                AddCurvesPopup.AddNewCurve(hierarchyNode);

                // Hold shift key to add new curves and keep window opened.
                if (Event.current.shift)
                {
                    m_TreeView.ReloadData();
                }
                else
                {
                    owner.Close();
                }
            }
        }
Пример #2
0
 internal static void AddNewCurve(AddCurvesPopupPropertyNode node)
 {
     AnimationWindowUtility.CreateDefaultCurves(s_State, node.curveBindings);
     if (NewCurveAddedCallback != null)
     {
         NewCurveAddedCallback(node);
     }
 }
        private TreeViewItem CreateNode(EditorCurveBinding[] curveBindings, TreeViewItem parentNode)
        {
            var node = new AddCurvesPopupPropertyNode(parentNode, curveBindings);

            // For RectTransform.position we only want .z
            if (AnimationWindowUtility.IsRectTransformPosition(node.curveBindings[0]))
            {
                node.curveBindings = new EditorCurveBinding[] { node.curveBindings[2] }
            }
            ;

            node.icon = parentNode.icon;
            return(node);
        }
        public override int CompareTo(TreeViewItem other)
        {
            AddCurvesPopupPropertyNode otherNode = other as AddCurvesPopupPropertyNode;

            if (otherNode != null)
            {
                if (displayName.Contains("Rotation") && otherNode.displayName.Contains("Position"))
                {
                    return(1);
                }
                if (displayName.Contains("Position") && otherNode.displayName.Contains("Rotation"))
                {
                    return(-1);
                }
            }
            return(base.CompareTo(other));
        }
 private void OnNewCurveAdded(AddCurvesPopupPropertyNode node)
 {
 }