Beispiel #1
0
        public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
        {
            base.OnRowGUI(rowRect, node, row, selected, focused);

            // 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, plusButtonStyle.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, GUIContent.none, plusButtonStyle))
            {
                AddCurvesPopup.AddNewCurve(hierarchyNode);
                owner.Close();
            }
        }
        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, plusButtonStyle.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, GUIContent.none, plusButtonStyle))
            {
                AddCurvesPopup.AddNewCurve(hierarchyNode);

                // Hold shift key to add new curves and keep window opened.
                if (Event.current.shift)
                {
                    m_TreeView.ReloadData();
                }
                else
                {
                    owner.Close();
                }
            }
        }
 internal static void AddNewCurve(AddCurvesPopupPropertyNode node)
 {
     AnimationWindowUtility.CreateDefaultCurves(s_State, node.selectionItem, node.curveBindings);
     if (NewCurveAddedCallback != null)
     {
         NewCurveAddedCallback(node);
     }
 }
 internal static void AddNewCurve(AddCurvesPopupPropertyNode node)
 {
     AnimationWindowUtility.CreateDefaultCurves(s_State, node.curveBindings);
     if (NewCurveAddedCallback != null)
     {
         NewCurveAddedCallback(node);
     }
 }
Beispiel #5
0
        private void OnNewCurveAdded(AddCurvesPopupPropertyNode node)
        {
            TreeViewItem treeViewItem = (!(node.parent.displayName == "GameObject")) ? node.parent.parent : node.parent;

            this.state.hierarchyState.selectedIDs.Clear();
            this.state.hierarchyState.selectedIDs.Add(treeViewItem.id);
            this.state.hierarchyData.SetExpanded(treeViewItem, true);
            this.state.hierarchyData.SetExpanded(node.parent.id, true);
        }
 internal static void AddNewCurve(AddCurvesPopupPropertyNode node)
 {
   AnimationWindowUtility.CreateDefaultCurves(AddCurvesPopup.s_State, node.curveBindings);
   TreeViewItem treeViewItem = !(node.parent.displayName == "GameObject") ? node.parent.parent : node.parent;
   AddCurvesPopup.s_State.hierarchyState.selectedIDs.Clear();
   AddCurvesPopup.s_State.hierarchyState.selectedIDs.Add(treeViewItem.id);
   AddCurvesPopup.s_State.hierarchyData.SetExpanded(treeViewItem, true);
   AddCurvesPopup.s_State.hierarchyData.SetExpanded(node.parent.id, true);
 }
Beispiel #7
0
        internal static void AddNewCurve(AddCurvesPopupPropertyNode node)
        {
            AnimationWindowUtility.CreateDefaultCurves(AddCurvesPopup.s_State, node.curveBindings);
            TreeViewItem treeViewItem = (!(node.parent.displayName == "GameObject")) ? node.parent.parent : node.parent;

            AddCurvesPopup.s_State.hierarchyState.selectedIDs.Clear();
            AddCurvesPopup.s_State.hierarchyState.selectedIDs.Add(treeViewItem.id);
            AddCurvesPopup.s_State.hierarchyData.SetExpanded(treeViewItem, true);
            AddCurvesPopup.s_State.hierarchyData.SetExpanded(node.parent.id, true);
        }
        private TreeViewItem CreateNode(EditorCurveBinding[] curveBindings, TreeViewItem parentNode)
        {
            AddCurvesPopupPropertyNode node = new AddCurvesPopupPropertyNode(parentNode, curveBindings);

            if (AnimationWindowUtility.IsRectTransformPosition(node.curveBindings[0]))
            {
                node.curveBindings = new EditorCurveBinding[] { node.curveBindings[2] };
            }
            node.icon = parentNode.icon;
            return(node);
        }
		internal static void AddNewCurve(AddCurvesPopupPropertyNode node)
		{
			if (!AnimationWindow.EnsureAllHaveClips())
			{
				return;
			}
			AnimationWindowUtility.CreateDefaultCurves(AddCurvesPopup.s_State, node.curveBindings);
			TreeViewItem treeViewItem = (!(node.parent.displayName == "GameObject")) ? node.parent.parent : node.parent;
			AddCurvesPopup.s_State.m_hierarchyState.selectedIDs.Clear();
			AddCurvesPopup.s_State.m_hierarchyState.selectedIDs.Add(treeViewItem.id);
			AddCurvesPopup.s_State.m_HierarchyData.SetExpanded(treeViewItem, true);
			AddCurvesPopup.s_State.m_HierarchyData.SetExpanded(node.parent.id, true);
			AddCurvesPopup.s_State.m_CurveEditorIsDirty = true;
		}
Beispiel #10
0
        private TreeViewItem CreateNode(EditorCurveBinding[] curveBindings, TreeViewItem parentNode, SerializedObject so)
        {
            var node = new AddCurvesPopupPropertyNode(parentNode, curveBindings, AnimationWindowUtility.GetNicePropertyDisplayName(curveBindings[0], so));

            // 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);
        }
        internal static void AddNewCurve(AddCurvesPopupPropertyNode node)
        {
            if (!AnimationWindow.EnsureAllHaveClips())
            {
                return;
            }
            AnimationWindowUtility.CreateDefaultCurves(AddCurvesPopup.s_State, node.curveBindings);
            TreeViewItem treeViewItem = (!(node.parent.displayName == "GameObject")) ? node.parent.parent : node.parent;

            AddCurvesPopup.s_State.m_hierarchyState.selectedIDs.Clear();
            AddCurvesPopup.s_State.m_hierarchyState.selectedIDs.Add(treeViewItem.id);
            AddCurvesPopup.s_State.m_HierarchyData.SetExpanded(treeViewItem, true);
            AddCurvesPopup.s_State.m_HierarchyData.SetExpanded(node.parent.id, true);
            AddCurvesPopup.s_State.m_CurveEditorIsDirty = true;
        }
        public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused)
        {
            base.OnRowGUI(rowRect, node, row, selected, focused);
            AddCurvesPopupPropertyNode addCurvesPopupPropertyNode = node as AddCurvesPopupPropertyNode;

            if (addCurvesPopupPropertyNode != null && addCurvesPopupPropertyNode.curveBindings != null && addCurvesPopupPropertyNode.curveBindings.Length != 0)
            {
                Rect position = new Rect(rowRect.width - 17f, rowRect.yMin, 17f, this.plusButtonStyle.fixedHeight);
                GUI.Box(position, GUIContent.none, this.plusButtonBackgroundStyle);
                if (GUI.Button(position, GUIContent.none, this.plusButtonStyle))
                {
                    AddCurvesPopup.AddNewCurve(addCurvesPopupPropertyNode);
                    this.owner.Close();
                }
            }
        }
        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));
        }
        public override Rect OnRowGUI(TreeViewItem node, int row, float rowWidth, bool selected, bool focused)
        {
            Rect result   = base.OnRowGUI(node, row, rowWidth, selected, focused);
            Rect position = new Rect(rowWidth - 17f, result.yMin, 17f, this.plusButtonStyle.fixedHeight);
            AddCurvesPopupPropertyNode addCurvesPopupPropertyNode = node as AddCurvesPopupPropertyNode;

            if (addCurvesPopupPropertyNode == null || addCurvesPopupPropertyNode.curveBindings == null || addCurvesPopupPropertyNode.curveBindings.Length == 0)
            {
                return(result);
            }
            GUI.Box(position, GUIContent.none, this.plusButtonBackgroundStyle);
            if (GUI.Button(position, GUIContent.none, this.plusButtonStyle))
            {
                AddCurvesPopup.AddNewCurve(addCurvesPopupPropertyNode);
                this.owner.Close();
                this.m_TreeView.ReloadData();
            }
            return(result);
        }
        public override int CompareTo(TreeViewItem other)
        {
            AddCurvesPopupPropertyNode addCurvesPopupPropertyNode = other as AddCurvesPopupPropertyNode;
            int result;

            if (addCurvesPopupPropertyNode != null)
            {
                if (this.displayName.Contains("Rotation") && addCurvesPopupPropertyNode.displayName.Contains("Position"))
                {
                    result = 1;
                    return(result);
                }
                if (this.displayName.Contains("Position") && addCurvesPopupPropertyNode.displayName.Contains("Rotation"))
                {
                    result = -1;
                    return(result);
                }
            }
            result = base.CompareTo(other);
            return(result);
        }
		private TreeViewItem CreateNode(EditorCurveBinding[] curveBindings, TreeViewItem parentNode)
		{
			AddCurvesPopupPropertyNode addCurvesPopupPropertyNode = new AddCurvesPopupPropertyNode(parentNode, curveBindings);
			if (AnimationWindowUtility.IsRectTransformPosition(addCurvesPopupPropertyNode.curveBindings[0]))
			{
				addCurvesPopupPropertyNode.curveBindings = new EditorCurveBinding[]
				{
					addCurvesPopupPropertyNode.curveBindings[2]
				};
			}
			addCurvesPopupPropertyNode.icon = parentNode.icon;
			return addCurvesPopupPropertyNode;
		}
 private void OnNewCurveAdded(AddCurvesPopupPropertyNode node)
 {
 }