Пример #1
0
 public override void NodeUI(UnityEditor.Graphs.GraphGUI host)
 {
     if (UnityEditor.Graphs.AnimationStateMachine.Node.IsLeftClick())
     {
         host.edgeGUI.EndSlotDragging(base.inputSlots.First <Slot>(), true);
     }
 }
Пример #2
0
 public override void NodeUI(UnityEditor.Graphs.GraphGUI host)
 {
     base.graphGUI = host as UnityEditor.Graphs.AnimationStateMachine.GraphGUI;
     Assert.NotNull(base.graphGUI);
     if (UnityEditor.Graphs.AnimationStateMachine.Node.IsLeftClick())
     {
         host.edgeGUI.EndSlotDragging(base.inputSlots.First <Slot>(), true);
     }
     if (UnityEditor.Graphs.AnimationStateMachine.Node.IsDoubleClick())
     {
         if (this.stateMachine == base.graphGUI.stateMachineGraph.parentStateMachine)
         {
             base.graphGUI.tool.GoToBreadCrumbTarget(this.stateMachine);
         }
         else
         {
             base.graphGUI.tool.AddBreadCrumb(this.stateMachine);
         }
         Event.current.Use();
     }
     if (UnityEditor.Graphs.AnimationStateMachine.Node.IsRightClick() && (this.stateMachine != base.graphGUI.stateMachineGraph.parentStateMachine))
     {
         GenericMenu menu = new GenericMenu();
         menu.AddItem(new GUIContent("Make Transition"), false, new GenericMenu.MenuFunction(this.MakeTransitionCallback));
         menu.AddItem(new GUIContent("Copy"), false, new GenericMenu.MenuFunction(this.CopyStateMachineCallback));
         menu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction(this.DeleteStateMachineCallback));
         menu.ShowAsContext();
         Event.current.Use();
     }
 }
Пример #3
0
        private void DoSlot(int id, Rect position, string title, Slot slot, bool allowStartDrag, bool allowEndDrag, bool allowMultiple, GUIStyle style)
        {
            slot.m_Position = GUIClip.Unclip(position);
            Event current = Event.current;

            switch (current.GetTypeForControl(id))
            {
            case EventType.MouseDown:
                if (position.Contains(Event.current.mousePosition) && current.button == 0)
                {
                    this.edgeGUI.BeginSlotDragging(slot, allowStartDrag, allowEndDrag);
                }
                break;

            case EventType.MouseUp:
                if (position.Contains(current.mousePosition) && current.button == 0)
                {
                    this.edgeGUI.EndSlotDragging(slot, allowMultiple);
                }
                break;

            case EventType.MouseDrag:
                if (position.Contains(current.mousePosition) && current.button == 0)
                {
                    this.edgeGUI.SlotDragging(slot, allowEndDrag, allowMultiple);
                }
                break;

            case EventType.Repaint:
                style.Draw(position, new GUIContent(title), id, GraphGUI.IsSlotActive(slot));
                break;
            }
        }
Пример #4
0
        internal virtual GraphGUI GetEditor()
        {
            GraphGUI graphGUI = ScriptableObject.CreateInstance <GraphGUI>();

            graphGUI.graph = this;
            return(graphGUI);
        }
Пример #5
0
 public override void NodeUI(GraphGUI host)
 {
     GUILayout.Label("Internal Nodes:" + this.m_SubGraph.nodes.Count, new GUILayoutOption[0]);
     if (GUILayout.Button("Ungroup", new GUILayoutOption[0]))
     {
         this.UnGroup();
     }
     if (GUILayout.Button("Edit", new GUILayoutOption[0]))
     {
         host.ZoomToGraph(this.m_SubGraph);
     }
 }
Пример #6
0
        public override void NodeUI(UnityEditor.Graphs.GraphGUI host)
        {
            base.graphGUI = host as UnityEditor.Graphs.AnimationStateMachine.GraphGUI;
            Assert.NotNull(base.graphGUI);
            Event current = Event.current;

            if (UnityEditor.Graphs.AnimationStateMachine.Node.IsRightClick())
            {
                GenericMenu menu = new GenericMenu();
                menu.AddItem(new GUIContent("Make Transition"), false, new GenericMenu.MenuFunction(this.MakeTransitionCallback));
                menu.ShowAsContext();
                current.Use();
            }
        }
Пример #7
0
 private void DeleteNodesAndEdges(List <Node> nodes, List <Edge> edges)
 {
     foreach (Edge current in edges)
     {
         this.m_Graph.RemoveEdge(current);
     }
     this.edgeGUI.edgeSelection.Clear();
     foreach (Edge current2 in GraphGUI.FindEdgesOfNodes(nodes, false))
     {
         this.m_Graph.RemoveEdge(current2);
     }
     foreach (Node current3 in nodes)
     {
         this.m_Graph.DestroyNode(current3);
     }
 }
Пример #8
0
 public virtual void OnToolbarGUI()
 {
     GUI.enabled = (this.selection.Count > 0);
     if (GUILayout.Button("Group " + this.selection.Count, EditorStyles.toolbarButton, new GUILayoutOption[0]))
     {
         Vector2 midPoint = GraphGUI.GetMidPoint(this.selection);
         Debug.Log("Grouping" + this.selection.Count + " nodes");
         Node node = GroupNode.FromNodes("GroupNode", this.selection, this.m_Graph.GetType());
         node.position = new Rect(midPoint.x - node.position.x / 2f, midPoint.y - node.position.y / 2f, node.position.width, node.position.height);
     }
     GUI.enabled = true;
     GUILayout.FlexibleSpace();
     GUI.enabled = EditorApplication.isPlaying;
     if (GUILayout.Button("Reload", EditorStyles.toolbarButton, new GUILayoutOption[0]))
     {
         InternalEditorUtility.RequestScriptReload();
     }
     GUI.enabled = true;
     GUILayout.Space(5f);
 }
Пример #9
0
        public override void NodeUI(Graphs.GraphGUI host)
        {
            base.NodeUI(host);

            if (_varlets.Length > 0)
            {
                _serializedObject.Update();
                var labelWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 100;

                using (new GUILayout.VerticalScope(Styles.varletContainer))
                {
                    foreach (var property in _varlets)
                    {
                        EditorGUILayout.PropertyField(property);
                    }
                }

                EditorGUIUtility.labelWidth = labelWidth;
                _serializedObject.ApplyModifiedProperties();
            }
        }
Пример #10
0
 public virtual void NodeUI(GraphGUI host)
 {
 }
Пример #11
0
        protected void DragSelection(Rect position)
        {
            int   controlID = GUIUtility.GetControlID(GraphGUI.kDragSelectionControlID, FocusType.Passive);
            Event current   = Event.current;

            switch (current.GetTypeForControl(controlID))
            {
            case EventType.MouseDown:
                if (position.Contains(current.mousePosition) && current.button == 0 && current.clickCount != 2 && !current.alt)
                {
                    GUIUtility.hotControl = controlID;
                    this.m_DragStartPoint = current.mousePosition;
                    this.m_OldSelection   = new List <Node>(this.selection);
                    Edge edge = this.edgeGUI.FindClosestEdge();
                    if (edge != null)
                    {
                        if (!EditorGUI.actionKey && !current.shift)
                        {
                            this.ClearSelection();
                        }
                        int item = this.m_Graph.edges.IndexOf(edge);
                        if (this.edgeGUI.edgeSelection.Contains(item))
                        {
                            this.edgeGUI.edgeSelection.Remove(item);
                        }
                        else
                        {
                            this.edgeGUI.edgeSelection.Add(item);
                        }
                        current.Use();
                    }
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == controlID)
                {
                    GUIUtility.hotControl = 0;
                    this.m_OldSelection.Clear();
                    this.UpdateUnitySelection();
                    this.m_IsDraggingSelection = GraphGUI.SelectionDragMode.None;
                    current.Use();
                }
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == controlID)
                {
                    if (!EditorGUI.actionKey && !current.shift && this.m_IsDraggingSelection == GraphGUI.SelectionDragMode.Pick)
                    {
                        this.ClearSelection();
                    }
                    this.m_IsDraggingSelection = GraphGUI.SelectionDragMode.Rect;
                    this.SelectNodesInRect(GraphGUI.FromToRect(this.m_DragStartPoint, current.mousePosition));
                    current.Use();
                }
                break;

            case EventType.KeyDown:
                if (this.m_IsDraggingSelection != GraphGUI.SelectionDragMode.None && current.keyCode == KeyCode.Escape)
                {
                    this.selection             = this.m_OldSelection;
                    GUIUtility.hotControl      = 0;
                    this.m_IsDraggingSelection = GraphGUI.SelectionDragMode.None;
                    current.Use();
                }
                break;

            case EventType.Repaint:
                if (this.m_IsDraggingSelection == GraphGUI.SelectionDragMode.Rect)
                {
                    Styles.selectionRect.Draw(GraphGUI.FromToRect(this.m_DragStartPoint, current.mousePosition), false, false, false, false);
                }
                break;
            }
        }
Пример #12
0
        protected void DragNodes()
        {
            Event current   = Event.current;
            int   controlID = GUIUtility.GetControlID(GraphGUI.kDragNodesControlID, FocusType.Passive);

            switch (current.GetTypeForControl(controlID))
            {
            case EventType.MouseDown:
                if (current.button == 0)
                {
                    this.m_LastMousePosition = GUIClip.Unclip(current.mousePosition);
                    this.m_DragNodeDistance  = Vector2.zero;
                    foreach (Node current2 in this.selection)
                    {
                        this.m_InitialDragNodePositions[current2] = current2.position;
                        current2.BeginDrag();
                    }
                    GUIUtility.hotControl = controlID;
                    current.Use();
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == controlID)
                {
                    foreach (Node current3 in this.selection)
                    {
                        current3.EndDrag();
                    }
                    this.m_InitialDragNodePositions.Clear();
                    GUIUtility.hotControl = 0;
                    current.Use();
                }
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == controlID)
                {
                    this.m_DragNodeDistance += GUIClip.Unclip(current.mousePosition) - this.m_LastMousePosition;
                    this.m_LastMousePosition = GUIClip.Unclip(current.mousePosition);
                    foreach (Node current4 in this.selection)
                    {
                        Rect position = current4.position;
                        Rect rect     = this.m_InitialDragNodePositions[current4];
                        position.x        = rect.x + this.m_DragNodeDistance.x;
                        position.y        = rect.y + this.m_DragNodeDistance.y;
                        current4.position = GraphGUI.SnapPositionToGrid(position);
                        current4.OnDrag();
                        current4.Dirty();
                    }
                    current.Use();
                }
                break;

            case EventType.KeyDown:
                if (GUIUtility.hotControl == controlID && current.keyCode == KeyCode.Escape)
                {
                    foreach (Node current5 in this.selection)
                    {
                        current5.position = GraphGUI.SnapPositionToGrid(this.m_InitialDragNodePositions[current5]);
                        current5.Dirty();
                    }
                    GUIUtility.hotControl = 0;
                    current.Use();
                }
                break;
            }
        }
Пример #13
0
        public override void NodeUI(UnityEditor.Graphs.GraphGUI host)
        {
            base.graphGUI = host as UnityEditor.Graphs.AnimationStateMachine.GraphGUI;
            Assert.NotNull(base.graphGUI);
            Event current = Event.current;

            if (UnityEditor.Graphs.AnimationStateMachine.Node.IsLeftClick())
            {
                host.edgeGUI.EndSlotDragging(base.inputSlots.First <Slot>(), true);
            }
            if (UnityEditor.Graphs.AnimationStateMachine.Node.IsDoubleClick())
            {
                Motion stateEffectiveMotion = AnimatorControllerTool.tool.animatorController.GetStateEffectiveMotion(this.state, AnimatorControllerTool.tool.selectedLayerIndex);
                if (stateEffectiveMotion is BlendTree)
                {
                    base.graphGUI.tool.AddBreadCrumb(this.state);
                }
                else if (stateEffectiveMotion is AnimationClip)
                {
                    Selection.activeObject = stateEffectiveMotion;
                    AnimationClipEditor.EditWithImporter(stateEffectiveMotion as AnimationClip);
                }
                current.Use();
            }
            if (UnityEditor.Graphs.AnimationStateMachine.Node.IsRightClick())
            {
                GenericMenu menu = new GenericMenu();
                menu.AddItem(new GUIContent("Make Transition"), false, new GenericMenu.MenuFunction(this.MakeTransitionCallback));
                if (base.graphGUI.rootStateMachine.defaultState == this.state)
                {
                    menu.AddDisabledItem(new GUIContent("Set as Layer Default State"));
                }
                else
                {
                    menu.AddItem(new GUIContent("Set as Layer Default State"), false, new GenericMenu.MenuFunction(this.SetDefaultCallback));
                }
                menu.AddItem(new GUIContent("Copy"), false, new GenericMenu.MenuFunction(this.CopyStateCallback));
                menu.AddItem(new GUIContent("Create new BlendTree in State"), false, new GenericMenu.MenuFunction(this.AddNewBlendTreeCallback));
                menu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction(this.DeleteStateCallback));
                menu.ShowAsContext();
                current.Use();
            }
            Rect rect = GUILayoutUtility.GetRect((float)200f, (float)10f);

            if ((Event.current.type == EventType.Repaint) && ((base.graphGUI.liveLinkInfo.currentState == this.state) || (base.graphGUI.liveLinkInfo.nextState == this.state)))
            {
                GUIStyle style  = "MeLivePlayBackground";
                GUIStyle style2 = "MeLivePlayBar";
                float    f      = (base.graphGUI.liveLinkInfo.currentState != this.state) ? base.graphGUI.liveLinkInfo.nextStateNormalizedTime : base.graphGUI.liveLinkInfo.currentStateNormalizedTime;
                bool     flag   = (base.graphGUI.liveLinkInfo.currentState != this.state) ? base.graphGUI.liveLinkInfo.nextStateLoopTime : base.graphGUI.liveLinkInfo.currentStateLoopTime;
                rect = style.margin.Remove(rect);
                Rect position = style.padding.Remove(rect);
                if (flag)
                {
                    if (f < 0f)
                    {
                        position.width = (position.width * (1f - (Mathf.Abs(f) % 1f))) + 2f;
                    }
                    else
                    {
                        position.width = (position.width * (f % 1f)) + 2f;
                    }
                }
                else
                {
                    position.width = (position.width * Mathf.Clamp(f, 0f, 1f)) + 2f;
                }
                style2.Draw(position, false, false, false, false);
                style.Draw(rect, false, false, false, false);
            }
        }