当前位置: 首页>>代码示例>>C#>>正文


C# StateMachine.GetState方法代码示例

本文整理汇总了C#中StateMachine.GetState方法的典型用法代码示例。如果您正苦于以下问题:C# StateMachine.GetState方法的具体用法?C# StateMachine.GetState怎么用?C# StateMachine.GetState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StateMachine的用法示例。


在下文中一共展示了StateMachine.GetState方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssignAnimationToCharacter

    /// <summary>
    /// Assigns the animation to the character.
    /// </summary>
    static void AssignAnimationToCharacter(AnimationClip clip, GameObject character)
    {
        //create a new controller
        UnityEditorInternal.AnimatorController my_controller = new UnityEditorInternal.AnimatorController();
        my_controller.name = "generic_controller";

        //check if the animator component is already attached to the character
        if (character.GetComponent<Animator>() == null)
            character.AddComponent<Animator>();

        //create the state machine with the animation clip
        StateMachine sm = new StateMachine();
        sm.AddState("default_state");
        sm.GetState(0).SetMotion(0, clip);

        //check if the controller already has a based layer
        if (my_controller.GetLayerCount() == 0)
            my_controller.AddLayer("Base Layer");
        //set the state machine
        my_controller.SetLayerStateMachine(0, sm);

        //assign the controller
        Animator animator = (Animator)character.GetComponent<Animator>();
        UnityEditorInternal.AnimatorController.SetAnimatorController(animator,my_controller);
    }
开发者ID:noa99kee,项目名称:character-model-detection,代码行数:28,代码来源:ScreenCapture.cs

示例2: GetTransitionNamesFromStateMachine

    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();
    }
开发者ID:Gibble,项目名称:UnityAnimatorEvents,代码行数:20,代码来源:AnimatorEventsEditor.cs

示例3: GetTransitionsCountFromStateMachine

    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;
    }
开发者ID:Gibble,项目名称:UnityAnimatorEvents,代码行数:19,代码来源:AnimatorEventsEditor.cs

示例4: GetStateNamesFromStateMachine

    private static string[] GetStateNamesFromStateMachine(StateMachine sm)
    {
        List<string> stateNames = new List<string>();

        for (int i = 0; i < sm.stateCount; ++i)
        {
            stateNames.Add(sm.GetState(i).uniqueName);
        }

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

        return stateNames.ToArray();
    }
开发者ID:Gibble,项目名称:UnityAnimatorEvents,代码行数:16,代码来源:AnimatorEventsEditor.cs

示例5: GetTransitionKeysFromStateMachine

    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();
    }
开发者ID:Gibble,项目名称:UnityAnimatorEvents,代码行数:20,代码来源:AnimatorEventsEditor.cs

示例6: GetStateKeysFromStateMachine

    private static int[] GetStateKeysFromStateMachine(StateMachine sm)
    {
        List<int> stateKeys = new List<int>();

        for (int i = 0; i < sm.stateCount; ++i)
        {
            stateKeys.Add(sm.GetState(i).uniqueNameHash);
        }

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

        return stateKeys.ToArray();
    }
开发者ID:Gibble,项目名称:UnityAnimatorEvents,代码行数:16,代码来源:AnimatorEventsEditor.cs

示例7: FromStateMachineToTransitionName

    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);
        }
    }
开发者ID:JobsSteve,项目名称:rushgame,代码行数:13,代码来源:AnimatorEventsEditor.cs

示例8: FromStateMachineToStateName

    private static void FromStateMachineToStateName(StateMachine stateMachine, List<string> stateNames)
    {
        for (int i = 0; i < stateMachine.stateCount; i++) {
            stateNames.Add(stateMachine.GetState(i).uniqueName);
        }

        for (int i = 0; i < stateMachine.stateMachineCount; i++) {
            FromStateMachineToStateName(stateMachine.GetStateMachine(i), stateNames);
        }
    }
开发者ID:JobsSteve,项目名称:rushgame,代码行数:10,代码来源:AnimatorEventsEditor.cs

示例9: FromStateMachineToStateKey

    private static void FromStateMachineToStateKey(StateMachine stateMachine, List<int> stateKeys)
    {
        for (int i = 0; i < stateMachine.stateCount; i++) {
            stateKeys.Add(stateMachine.GetState(i).uniqueNameHash);
        }

        for (int i = 0; i < stateMachine.stateMachineCount; i++) {
            FromStateMachineToStateKey(stateMachine.GetStateMachine(i), stateKeys);
        }
    }
开发者ID:JobsSteve,项目名称:rushgame,代码行数:10,代码来源:AnimatorEventsEditor.cs

示例10: SetAnimator

	// Create and assign controller and animation
	void SetAnimator()
	{
		// Add the component if it's not already there
		if (gameObject.GetComponent<Animator>() == null)
			gameObject.AddComponent<Animator>();
			
		charAnimator = (Animator)gameObject.GetComponent<Animator>();

		// Set speed to 0 so no real animation takes place
		charAnimator.speed = 0.0f;
		
		UnityEditorInternal.AnimatorController aController = new UnityEditorInternal.AnimatorController();
		aController.name = "animation_controller";
		
		if (aController.GetLayerCount() == 0)
			aController.AddLayer("Base");
		
		StateMachine sm = new StateMachine();
		sm.AddState("default");
		
		// Add clip
		sm.GetState(0).SetMotion(0, (AnimationClip)animations[animCount]);
		animCount++;
		
		aController.SetLayerStateMachine(0, sm);
		
		UnityEditorInternal.AnimatorController.SetAnimatorController(charAnimator, aController);
		
		// Set time
		currTime = charAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime;
	}
开发者ID:noa99kee,项目名称:character-model-detection,代码行数:32,代码来源:CharacterScript.cs


注:本文中的StateMachine.GetState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。