GetTransitionsFromState() public method

public GetTransitionsFromState ( UnityEditorInternal srcState ) : UnityEditorInternal.Transition[]
srcState UnityEditorInternal
return UnityEditorInternal.Transition[]
コード例 #1
0
        public static void ProcessAllTransitions(Animator animator, ProcessAnimatorTransition callback)
        {
            AnimatorController controller = GetInternalAnimatorController(animator);
            int layerCount = controller.layerCount;

            for (int layer = 0; layer < layerCount; layer++)
            {
                string layerName = controller.GetLayer(layer).name;
                UnityEditorInternal.StateMachine sm = controller.GetLayer(layer).stateMachine;
                //Handle anyState cases. see UnityEditorInternal.StateMachine.transitions
                {
                    Transition[] anyTransitions = sm.GetTransitionsFromState(null);
                    foreach (var t in anyTransitions)
                    {
                        TransitionInfo info = new TransitionInfo(t.uniqueNameHash, t.uniqueName, layer, layerName,
                                                                 0, t.dstState.uniqueNameHash, t.atomic, t.duration, t.mute, t.offset, t.solo);
                        callback(info);
                    }
                }
                for (int i = 0; i < sm.stateCount; i++)
                {
                    UnityEditorInternal.State state = sm.GetState(i);
                    Transition[] transitions        = sm.GetTransitionsFromState(state);
                    foreach (var t in transitions)
                    {
//						Debug.Log (state.uniqueName +  ", transition: " + t.uniqueName + " ---" + " dest = " + t.dstState + " (" + (Animator.StringToHash (state.uniqueName) == Animator.StringToHash (layerName + "." + t.dstState)) + ") " + " src = " + t.srcState);
                        TransitionInfo info = new TransitionInfo(t.uniqueNameHash, t.uniqueName, layer, layerName,
                                                                 t.srcState.uniqueNameHash, t.dstState.uniqueNameHash, t.atomic, t.duration, t.mute, t.offset, t.solo);
                        callback(info);
                    }
                }
            }
        }
コード例 #2
0
    /// <summary>
    /// Gets the count of transitions in a layer.
    /// </summary>
    /// <returns>
    /// The transition count.
    /// </returns>
    /// <param name='animator'>
    /// Animator.
    /// </param>
    /// <param name='layer'>
    /// Layer.
    /// </param>
    public static int GetTransitionsCount(Animator animator, int layer)
    {
        UnityEditorInternal.AnimatorController ac           = animator.runtimeAnimatorController as UnityEditorInternal.AnimatorController;
        UnityEditorInternal.StateMachine       stateMachine = ac.GetLayer(layer).stateMachine;

        int counter = 0;

        for (int i = 0; i < stateMachine.stateCount; i++)
        {
            Transition[] trans = stateMachine.GetTransitionsFromState(stateMachine.GetState(i));
            counter += trans.Length;
        }

        return(counter);

//		return stateMachine.transitionCount;
    }
コード例 #3
0
    private static int GetTransitionsCountFromStateMachine(StateMachine sm)
    {
        int total = 0;
        List<Transition> transitions = new List<Transition>();

        for (int i = 0; i < sm.stateCount; ++i)
        {
            transitions.AddRange(sm.GetTransitionsFromState(sm.GetState(i)));
        }

        total = transitions.Count;

        for (int i = 0; i < sm.stateMachineCount; ++i)
        {
            total += GetTransitionsCountFromStateMachine(sm.GetStateMachine(i));
        }

        return total;
    }
コード例 #4
0
    private static string[] GetTransitionNamesFromStateMachine(StateMachine sm)
    {
        List<string> transitionNames = new List<string>();
        List<Transition> transitions = new List<Transition>();

        for (int i = 0; i < sm.stateCount; ++i)
        {
            transitions.AddRange(sm.GetTransitionsFromState(sm.GetState(i)));
        }

        foreach (Transition transition in transitions)
            transitionNames.Add(transition.uniqueName);

        for (int i = 0; i < sm.stateMachineCount; ++i)
        {
            transitionNames.AddRange(GetTransitionNamesFromStateMachine(sm.GetStateMachine(i)));
        }

        return transitionNames.ToArray();
    }
コード例 #5
0
    private static int[] GetTransitionKeysFromStateMachine(StateMachine sm)
    {
        List<int> transitionKeys = new List<int>();
        List<Transition> transitions = new List<Transition>();

        for (int i = 0; i < sm.stateCount; ++i)
        {
            transitions.AddRange(sm.GetTransitionsFromState(sm.GetState(i)));
        }

        foreach (Transition transition in transitions)
            transitionKeys.Add(transition.uniqueNameHash);

        for (int i = 0; i < sm.stateMachineCount; ++i)
        {
            transitionKeys.AddRange(GetTransitionKeysFromStateMachine(sm.GetStateMachine(i)));
        }

        return transitionKeys.ToArray();
    }
コード例 #6
0
    private static void FromStateMachineToTransitionName(StateMachine stateMachine, List<string> transitionNames)
    {
        for (int i = 0; i < stateMachine.stateCount; i++) {
            Transition[] trans = stateMachine.GetTransitionsFromState(stateMachine.GetState(i));
            foreach(Transition tran in trans) {
                transitionNames.Add(tran.uniqueName);
            }
        }

        for (int i = 0; i < stateMachine.stateMachineCount; i++) {
            FromStateMachineToTransitionName(stateMachine.GetStateMachine(i), transitionNames);
        }
    }