Example #1
0
        private void DeleteSelectedEdges()
        {
            bool        flag = false;
            List <Edge> list = new List <Edge>();

            foreach (int current in this.edgeGUI.edgeSelection)
            {
                list.Add(base.graph.edges[current]);
                flag = true;
            }
            foreach (Edge current2 in list)
            {
                EdgeInfo edgeInfo = this.stateMachineGraph.GetEdgeInfo(current2);
                foreach (TransitionEditionContext current3 in edgeInfo.transitions)
                {
                    current3.Remove(false);
                    flag = true;
                }
            }
            if (flag)
            {
                this.stateMachineGraph.RebuildGraph();
            }
            this.edgeGUI.edgeSelection.Clear();
        }
Example #2
0
 protected void ComputeTransitionContexts()
 {
     this.m_TransitionContexts = new TransitionEditionContext[base.targets.Length];
     UnityEditor.Graphs.AnimationStateMachine.Graph    graph = (AnimatorControllerTool.tool == null) ? null : AnimatorControllerTool.tool.stateMachineGraph;
     UnityEditor.Graphs.AnimationStateMachine.GraphGUI hgui  = (AnimatorControllerTool.tool == null) ? null : AnimatorControllerTool.tool.stateMachineGraphGUI;
     for (int i = 0; i < base.targets.Length; i++)
     {
         AnimatorTransitionBase aTransition = base.targets[i] as AnimatorTransitionBase;
         this.m_TransitionContexts[i] = new TransitionEditionContext(aTransition, null, null, null);
         if ((graph != null) && (hgui != null))
         {
             foreach (int num2 in hgui.edgeGUI.edgeSelection)
             {
                 EdgeInfo edgeInfo = graph.GetEdgeInfo(graph.edges[num2]);
                 foreach (TransitionEditionContext context in edgeInfo.transitions)
                 {
                     if (context.transition == aTransition)
                     {
                         this.m_TransitionContexts[i] = context;
                     }
                 }
             }
         }
     }
 }
Example #3
0
        private List <string> CollectSelectionNames()
        {
            List <string> list = new List <string>();

            foreach (UnityEditor.Graphs.AnimationStateMachine.Node node in base.selection)
            {
                if (node is StateNode)
                {
                    list.Add((node as StateNode).state.name);
                }
                else if (node is StateMachineNode)
                {
                    AnimatorStateMachine stateMachine = (node as StateMachineNode).stateMachine;
                    if (this.parentStateMachine != stateMachine)
                    {
                        list.Add(stateMachine.name);
                    }
                }
            }
            foreach (int num in this.edgeGUI.edgeSelection)
            {
                EdgeInfo edgeInfo = this.stateMachineGraph.GetEdgeInfo(base.graph.edges[num]);
                foreach (TransitionEditionContext context in edgeInfo.transitions)
                {
                    if (!context.isDefaultTransition)
                    {
                        list.Add(context.displayName);
                    }
                }
            }
            return(list);
        }
        protected void ComputeTransitionContexts()
        {
            this.m_TransitionContexts = new TransitionEditionContext[base.targets.Length];
            Graph    graph    = (!AnimatorControllerTool.tool) ? null : AnimatorControllerTool.tool.stateMachineGraph;
            GraphGUI graphGUI = (!AnimatorControllerTool.tool) ? null : AnimatorControllerTool.tool.stateMachineGraphGUI;

            for (int i = 0; i < base.targets.Length; i++)
            {
                AnimatorTransitionBase animatorTransitionBase = base.targets[i] as AnimatorTransitionBase;
                this.m_TransitionContexts[i] = new TransitionEditionContext(animatorTransitionBase, null, null, null);
                if (graph != null && graphGUI != null)
                {
                    foreach (int current in graphGUI.edgeGUI.edgeSelection)
                    {
                        EdgeInfo edgeInfo = graph.GetEdgeInfo(graph.edges[current]);
                        foreach (TransitionEditionContext current2 in edgeInfo.transitions)
                        {
                            if (current2.transition == animatorTransitionBase)
                            {
                                this.m_TransitionContexts[i] = current2;
                            }
                        }
                    }
                }
            }
        }
Example #5
0
        private void DeleteSelectedEdges()
        {
            bool flag = false;
            List <UnityEditor.Graphs.Edge> list = new List <UnityEditor.Graphs.Edge>();

            foreach (int num in this.edgeGUI.edgeSelection)
            {
                list.Add(base.graph.edges[num]);
                flag = true;
            }
            foreach (UnityEditor.Graphs.Edge edge in list)
            {
                EdgeInfo edgeInfo = this.stateMachineGraph.GetEdgeInfo(edge);
                foreach (TransitionEditionContext context in edgeInfo.transitions)
                {
                    context.Remove(false);
                    flag = true;
                }
            }
            if (flag)
            {
                this.stateMachineGraph.RebuildGraph();
            }
            this.edgeGUI.edgeSelection.Clear();
        }
Example #6
0
 public bool CopySelectionToPasteboard()
 {
     UnityEngine.Object[] array       = new UnityEngine.Object[0];
     Vector3[]            vectorArray = new Vector3[0];
     foreach (UnityEditor.Graphs.AnimationStateMachine.Node node in base.selection)
     {
         if (node is StateNode)
         {
             ArrayUtility.Add <UnityEngine.Object>(ref array, (node as StateNode).state);
             ArrayUtility.Add <Vector3>(ref vectorArray, new Vector3(node.position.x, node.position.y, 0f));
         }
         else if ((node is StateMachineNode) && ((node as StateMachineNode).stateMachine != AnimatorControllerTool.tool.stateMachineGraph.parentStateMachine))
         {
             ArrayUtility.Add <UnityEngine.Object>(ref array, (node as StateMachineNode).stateMachine);
             ArrayUtility.Add <Vector3>(ref vectorArray, new Vector3(node.position.x, node.position.y, 0f));
         }
     }
     foreach (int num in this.edgeGUI.edgeSelection)
     {
         EdgeInfo edgeInfo = this.stateMachineGraph.GetEdgeInfo(base.graph.edges[num]);
         foreach (TransitionEditionContext context in edgeInfo.transitions)
         {
             if (context.transition != null)
             {
                 ArrayUtility.Add <UnityEngine.Object>(ref array, context.transition);
                 ArrayUtility.Add <Vector3>(ref vectorArray, Vector3.zero);
             }
         }
     }
     Unsupported.CopyStateMachineDataToPasteboard(array, vectorArray, this.tool.animatorController, this.tool.selectedLayerIndex);
     return(array.Length > 0);
 }
Example #7
0
 public override void SyncGraphToUnitySelection()
 {
     if (GUIUtility.hotControl != 0)
     {
         return;
     }
     this.selection.Clear();
     this.edgeGUI.edgeSelection.Clear();
     UnityEngine.Object[] objects = Selection.objects;
     for (int i = 0; i < objects.Length; i++)
     {
         UnityEngine.Object @object                    = objects[i];
         Node                   node                   = null;
         AnimatorState          animatorState          = @object as AnimatorState;
         AnimatorStateMachine   animatorStateMachine   = @object as AnimatorStateMachine;
         AnimatorTransitionBase animatorTransitionBase = @object as AnimatorTransitionBase;
         if (animatorState != null)
         {
             node = this.stateMachineGraph.FindNode(animatorState);
         }
         else if (animatorStateMachine != null)
         {
             node = this.stateMachineGraph.FindNode(animatorStateMachine);
         }
         else if (animatorTransitionBase != null)
         {
             foreach (Edge current in this.m_Graph.edges)
             {
                 EdgeInfo edgeInfo = this.stateMachineGraph.GetEdgeInfo(current);
                 foreach (TransitionEditionContext current2 in edgeInfo.transitions)
                 {
                     if (current2.transition == animatorTransitionBase)
                     {
                         int item = this.m_Graph.edges.IndexOf(current);
                         if (!this.edgeGUI.edgeSelection.Contains(item))
                         {
                             this.edgeGUI.edgeSelection.Add(item);
                         }
                     }
                 }
             }
         }
         else
         {
             node = (@object as Node);
         }
         if (node != null)
         {
             this.selection.Add(node);
         }
     }
 }
Example #8
0
        protected override void UpdateUnitySelection()
        {
            List <UnityEngine.Object> list = new List <UnityEngine.Object>();

            foreach (UnityEditor.Graphs.Node current in this.selection)
            {
                if (current is StateNode)
                {
                    list.Add((current as StateNode).state);
                }
                if (current is StateMachineNode)
                {
                    list.Add((current as StateMachineNode).stateMachine);
                }
                if (current is AnyStateNode)
                {
                    list.Add(current);
                }
                if (current is EntryNode)
                {
                    list.Add(current);
                }
                if (current is ExitNode)
                {
                    list.Add(current);
                }
            }
            foreach (int current2 in this.edgeGUI.edgeSelection)
            {
                EdgeInfo edgeInfo = this.stateMachineGraph.GetEdgeInfo(base.graph.edges[current2]);
                foreach (TransitionEditionContext current3 in edgeInfo.transitions)
                {
                    if (current3.transition != null)
                    {
                        list.Add(current3.transition);
                    }
                    else
                    {
                        this.m_DefaultTransition = ScriptableObject.CreateInstance <AnimatorDefaultTransition>();
                        list.Add(this.m_DefaultTransition);
                    }
                }
            }
            if (list.Count > 0)
            {
                Selection.objects = list.ToArray();
            }
        }
Example #9
0
 public void DoEdges()
 {
     if (Event.current.type == EventType.Repaint)
     {
         int num = 0;
         foreach (Edge current in this.host.graph.edges)
         {
             Texture2D tex      = (Texture2D)Styles.connectionTexture.image;
             Color     color    = current.color;
             EdgeInfo  edgeInfo = this.smHost.stateMachineGraph.GetEdgeInfo(current);
             if (edgeInfo != null)
             {
                 if (edgeInfo.hasDefaultState)
                 {
                     color = EdgeGUI.defaultTransitionColor;
                 }
                 else if (edgeInfo.edgeType == EdgeType.Transition)
                 {
                     color = EdgeGUI.selectorTransitionColor;
                 }
             }
             bool flag = false;
             int  num2 = 0;
             while (num2 < this.edgeSelection.Count && !flag)
             {
                 if (this.edgeSelection[num2] == num)
                 {
                     color = EdgeGUI.selectedEdgeColor;
                     flag  = true;
                 }
                 num2++;
             }
             this.DrawEdge(current, tex, color, edgeInfo);
             num++;
         }
     }
     if (this.IsDragging())
     {
         EdgeGUI.s_TargetDraggingSlot = null;
         Event.current.Use();
     }
     if (this.ShouldStopDragging())
     {
         this.EndDragging();
         Event.current.Use();
     }
 }
Example #10
0
        private void DrawEdge(Edge edge, Texture2D tex, Color color, EdgeInfo info)
        {
            Vector3 cross;

            Vector3[] edgePoints = EdgeGUI.GetEdgePoints(edge, out cross);
            Handles.color = color;
            if (edgePoints[0] == edgePoints[1])
            {
                EdgeGUI.DrawArrows(color, -Vector3.right, new Vector3[]
                {
                    edgePoints[0] + new Vector3(0f, 31f, 0f),
                    edgePoints[0] + new Vector3(0f, 30f, 0f)
                }, info, true);
            }
            else
            {
                Handles.DrawAAPolyLine(tex, 5f, new Vector3[]
                {
                    edgePoints[0],
                    edgePoints[1]
                });
                EdgeGUI.DrawArrows(color, cross, edgePoints, info, false);
                if (info != null)
                {
                    bool flag  = this.smHost.liveLinkInfo.srcNode == edge.fromSlot.node;
                    bool flag2 = this.smHost.liveLinkInfo.dstNode == edge.toSlot.node;
                    if ((flag && flag2) || (flag2 && this.smHost.liveLinkInfo.transitionInfo.entry && edge.fromSlot.node is EntryNode) || (flag && this.smHost.liveLinkInfo.transitionInfo.exit && edge.toSlot.node is ExitNode) || (flag2 && this.smHost.liveLinkInfo.transitionInfo.anyState && edge.fromSlot.node is AnyStateNode))
                    {
                        float num = this.smHost.liveLinkInfo.transitionInfo.normalizedTime;
                        if (this.smHost.liveLinkInfo.currentStateMachine != this.smHost.liveLinkInfo.nextStateMachine)
                        {
                            num = num % 0.5f / 0.5f;
                        }
                        Handles.color = EdgeGUI.selectedEdgeColor;
                        Handles.DrawAAPolyLine(10f, new Vector3[]
                        {
                            edgePoints[0],
                            edgePoints[1] * num + edgePoints[0] * (1f - num)
                        });
                    }
                }
            }
        }
Example #11
0
        private List <string> CollectSelectionNames()
        {
            List <string> list = new List <string>();

            using (List <UnityEditor.Graphs.Node> .Enumerator enumerator = this.selection.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Node node = (Node)enumerator.Current;
                    if (node is StateNode)
                    {
                        list.Add((node as StateNode).state.name);
                    }
                    else if (node is StateMachineNode)
                    {
                        AnimatorStateMachine stateMachine = (node as StateMachineNode).stateMachine;
                        if (this.parentStateMachine != stateMachine)
                        {
                            list.Add(stateMachine.name);
                        }
                    }
                }
            }
            foreach (int current in this.edgeGUI.edgeSelection)
            {
                EdgeInfo edgeInfo = this.stateMachineGraph.GetEdgeInfo(base.graph.edges[current]);
                foreach (TransitionEditionContext current2 in edgeInfo.transitions)
                {
                    if (!current2.isDefaultTransition)
                    {
                        list.Add(current2.displayName);
                    }
                }
            }
            return(list);
        }
Example #12
0
 public bool CopySelectionToPasteboard()
 {
     UnityEngine.Object[] array         = new UnityEngine.Object[0];
     Vector3[]            monoPositions = new Vector3[0];
     using (List <UnityEditor.Graphs.Node> .Enumerator enumerator = this.selection.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             Node node = (Node)enumerator.Current;
             if (node is StateNode)
             {
                 ArrayUtility.Add <UnityEngine.Object>(ref array, (node as StateNode).state);
                 ArrayUtility.Add <Vector3>(ref monoPositions, new Vector3(node.position.x, node.position.y, 0f));
             }
             else if (node is StateMachineNode && (node as StateMachineNode).stateMachine != AnimatorControllerTool.tool.stateMachineGraph.parentStateMachine)
             {
                 ArrayUtility.Add <UnityEngine.Object>(ref array, (node as StateMachineNode).stateMachine);
                 ArrayUtility.Add <Vector3>(ref monoPositions, new Vector3(node.position.x, node.position.y, 0f));
             }
         }
     }
     foreach (int current in this.edgeGUI.edgeSelection)
     {
         EdgeInfo edgeInfo = this.stateMachineGraph.GetEdgeInfo(base.graph.edges[current]);
         foreach (TransitionEditionContext current2 in edgeInfo.transitions)
         {
             if (current2.transition != null)
             {
                 ArrayUtility.Add <UnityEngine.Object>(ref array, current2.transition);
                 ArrayUtility.Add <Vector3>(ref monoPositions, Vector3.zero);
             }
         }
     }
     Unsupported.CopyStateMachineDataToPasteboard(array, monoPositions, this.tool.animatorController, this.tool.selectedLayerIndex);
     return(array.Length > 0);
 }
Example #13
0
        private static void DrawArrows(Color color, Vector3 cross, Vector3[] edgePoints, EdgeInfo info, bool isSelf)
        {
            Vector3 a          = edgePoints[1] - edgePoints[0];
            Vector3 normalized = a.normalized;
            Vector3 a2         = a * 0.5f + edgePoints[0];

            a2 -= cross * 0.5f;
            int num = 1;

            if (info != null && info.hasMultipleTransitions)
            {
                num = 3;
            }
            for (int i = 0; i < num; i++)
            {
                Color color2 = color;
                if (info != null)
                {
                    if (info.debugState == EdgeDebugState.MuteAll)
                    {
                        color2 = Color.red;
                    }
                    else if (info.debugState == EdgeDebugState.SoloAll)
                    {
                        color2 = Color.green;
                    }
                    else if (i == 0)
                    {
                        if (info.debugState == EdgeDebugState.MuteSome || info.debugState == EdgeDebugState.MuteAndSolo)
                        {
                            color2 = Color.red;
                        }
                        if (info.debugState == EdgeDebugState.SoloSome)
                        {
                            color2 = Color.green;
                        }
                    }
                    else if (i == 2 && info.debugState == EdgeDebugState.MuteAndSolo)
                    {
                        color2 = Color.green;
                    }
                    if (i == 1 && info.edgeType == EdgeType.MixedTransition)
                    {
                        color2 = EdgeGUI.selectorTransitionColor;
                    }
                }
                Vector3 center = a2 + (float)((num != 1) ? (i - 1) : i) * 13f * ((!isSelf) ? normalized : cross);
                EdgeGUI.DrawArrow(color2, cross, normalized, center);
            }
        }