• 代码添加动画控制器


    代码添加动画控制器

     1 // Creates the controller
     2 var controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath ("Assets/Mecanim/StateMachineTransitions.controller");
     3 
     4 // Add parameters
     5 controller.AddParameter(“TransitionNow”, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
     6 controller.AddParameter(“Reset”, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
     7 controller.AddParameter(“GotoB1″, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
     8 controller.AddParameter(“GotoC”, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
     9 
    10 // Add StateMachines
    11 var rootStateMachine = controller.layers[0].stateMachine;
    12 var stateMachineA = rootStateMachine.AddStateMachine(“smA”);
    13 var stateMachineB = rootStateMachine.AddStateMachine(“smB”);
    14 var stateMachineC = stateMachineB.AddStateMachine(“smC”);
    15 
    16 // Add States
    17 var stateA1 = stateMachineA.AddState(“stateA1″);
    18 var stateB1 = stateMachineB.AddState(“stateB1″);
    19 var stateB2 = stateMachineB.AddState(“stateB2″);
    20 stateMachineC.AddState(“stateC1″);
    21 var stateC2 = stateMachineC.AddState(“stateC2″); // don’t add an entry transition, should entry to state by default
    22 
    23 // Add Transitions
    24 var exitTransition = stateA1.AddExitTransition();
    25 exitTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “TransitionNow”);
    26 exitTransition.duration = 0;
    27 
    28 var resetTransition = stateMachineA.AddAnyStateTransition(stateA1);
    29 resetTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “Reset”);
    30 resetTransition.duration = 0;
    31 
    32 var transitionB1 = stateMachineB.AddEntryTransition(stateB1);
    33 transitionB1.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “GotoB1″);
    34 stateMachineB.AddEntryTransition(stateB2);
    35 stateMachineC.defaultState = stateC2;
    36 var exitTransitionC2 = stateC2.AddExitTransition();
    37 exitTransitionC2.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “TransitionNow”);
    38 exitTransitionC2.duration = 0;
    39 
    40 var stateMachineTransition = rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineC);
    41 stateMachineTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “GotoC”);
    42 rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineB);
  • 相关阅读:
    整理sql server数据类型
    【MVC4升级到MVC5】ASP.Net MVC 4项目升级MVC 5的方法
    MVC学习笔记:入门
    maven第一次创建项目太慢解决方法
    idea中创建maven的Javaweb工程并进行配置
    idea中MavenWeb项目不能创建Servlet的解决办法
    Java模拟客户端向服务器上传文件
    Java学习随笔---常用API(二)
    ssh设置超时时间
    linux 登陆失败处理
  • 原文地址:https://www.cnblogs.com/GameDeveloper/p/4281243.html
Copyright © 2020-2023  润新知