unity 等待...动画
The animation team has been working hard to pull together an impressive feature set for Unity 5.0. Here’s a quick overview of the new animation features you can look forward to!
动画团队一直在努力为Unity 5.0整合令人印象深刻的功能集。 这是您可以期待的新动画功能的快速概述!
In Unity 5, you’ll be able to add StateMachineBehaviour scripts to your states, and receive the following callbacks when the states are played:
在Unity 5中,您将能够将StateMachineBehaviour脚本添加到您的状态,并在播放状态时接收以下回调:
OnStateEnter
OnStateEnter
OnStateUpdate
OnStateUpdate
OnStateExit
OnStateExit
OnStateMove
OnStateMove
OnStateIK
OnStateIK
You can have as many StateMachineBehaviours in your State as you like. So to add IK on State, or to do some custom logic, simply drag the StateMachineBehaviour script on to it.
您可以根据需要在自己的州中拥有任意数量的StateMachineBehaviours。 因此,要在State上添加IK或执行一些自定义逻辑,只需将StateMachineBehaviour脚本拖到其上即可。
Basically, anything that requires some kind of StateMachine logic in your game – with or without animation – can use this.
基本上,任何需要在游戏中使用某种StateMachine逻辑(带有或不带有动画)的东西都可以使用此功能。
1
2
|
if(animator.GetCurrentAnimatorStateInfo(0).isName("Idle") )
DoStuff()
|
1
2
|
if ( animator . GetCurrentAnimatorStateInfo ( 0 ) . isName ( "Idle" ) )
DoStuff ( )
|
(which I’m sure you have plenty of in your code),
(我确定您的代码中有很多),
you can just use StateMachineBehaviours instead!
您可以改用StateMachineBehaviours!
State Machines are growing more and more complex, so we introduced the concept of State Machine Transitions to provide a higher level of abstraction over the StateMachine logic.
状态机变得越来越复杂,因此我们引入了状态机转换的概念,以提供对StateMachine逻辑的更高级别的抽象。
In Unity 5, we’ve added Entry and Exit nodes to StateMachines. There are used during State Machine Transitions.
在Unity 5中,我们已将Entry和Exit节点添加到StateMachines。 在状态机转换期间使用。
Entry: When you transition to a StateMachine, the animation system will evaluate the Entry node and branch to the destination that its conditions meet.
Entry:过渡到StateMachine时,动画系统将评估Entry节点并跳转到其条件满足的目标。
Exit: When going to the Exit node, the animation system will look at the outgoing StateMachine transitions and branch to the proper destination.
退出:转到“退出”节点时,动画系统将查看传出的StateMachine过渡并分支到正确的目标。
Note that you can mix transitions: State->State, State->StateMachine, StateMachine->StateMachine…
请注意,您可以混合转换:State-> State,State-> StateMachine,StateMachine-> StateMachine…
What’s more, we also revamped the UI for our tool so you can now re-order your parameters and layers.
更重要的是,我们还改进了工具的用户界面,以便您现在可以重新排序参数和图层。
In Unity 5 you can create animation assets; StateMachines, States, Controllers, Layers, Blentrees, etc., using scripts in the Editor!
在Unity 5中,您可以创建动画资源。 在编辑器中使用脚本来编辑StateMachines,状态,控制器,层,Blentree等!
There are two APIs, a high-level one, where the assets are managed by Unity and a low level one where you manage assets manually, and can perform external referencing.
有两种API,一种是高级API,用于由Unity管理资产;另一种是低级API,用于手动管理资产,并且可以执行外部引用。
Both APIs are documented, and I’ve put a small example of API usage at the end of this post.
这两个API都有文档记录,并且在本文的结尾处我举了一个API使用情况的小例子。
We’ve added a new type of BlendTree that allows you to map an animator parameter to the weight of a BlendTree child directly.
我们添加了一种新的BlendTree类型,它允许您将动画师参数直接映射到BlendTree子项的权重。
This can come in really handy if you’re working with BlendShape animations, or additive animations.
如果您正在使用BlendShape动画或附加动画,这会非常方便。
Root Motion Authoring (in generic mode) Unity 5 also allows you to animate objects and convert their animator to root motion (ie Delta Animation). Simply create an animation – translation/rotation – on the topmost transform of an object then click Generate Root Motion Curve in the AnimationClip inspector!
根动画创作(在常规模式下) Unity 5还允许您为对象设置动画并将其动画制作者转换为根动画(即Delta动画)。 只需在对象的最上层变换上创建动画-平移/旋转-然后在AnimationClip检查器中单击“生成根运动曲线”!
More stuff that will make your life easier:
更多可以使您的生活更轻松的事物:
Let us know what you think of these changes!
让我们知道您对这些变化的看法!
The Animation Team.
动画团队。
More about Unity 5.
有关Unity 5的更多信息。
Asset Creation API sample Code
资产创建API示例代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Creates the controller
var controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath ("Assets/Mecanim/StateMachineTransitions.controller");
// Add parameters
controller.AddParameter(“TransitionNow”, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
controller.AddParameter(“Reset”, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
controller.AddParameter(“GotoB1″, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
controller.AddParameter(“GotoC”, UnityEditor.Animations.AnimatorControllerParameterType.Trigger);
// Add StateMachines
var rootStateMachine = controller.layers[0].stateMachine;
var stateMachineA = rootStateMachine.AddStateMachine(“smA”);
var stateMachineB = rootStateMachine.AddStateMachine(“smB”);
var stateMachineC = stateMachineB.AddStateMachine(“smC”);
// Add States
var stateA1 = stateMachineA.AddState(“stateA1″);
var stateB1 = stateMachineB.AddState(“stateB1″);
var stateB2 = stateMachineB.AddState(“stateB2″);
stateMachineC.AddState(“stateC1″);
var stateC2 = stateMachineC.AddState(“stateC2″); // don’t add an entry transition, should entry to state by default
// Add Transitions
var exitTransition = stateA1.AddExitTransition();
exitTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “TransitionNow”);
exitTransition.duration = 0;
var resetTransition = stateMachineA.AddAnyStateTransition(stateA1);
resetTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “Reset”);
resetTransition.duration = 0;
var transitionB1 = stateMachineB.AddEntryTransition(stateB1);
transitionB1.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “GotoB1″);
stateMachineB.AddEntryTransition(stateB2);
stateMachineC.defaultState = stateC2;
var exitTransitionC2 = stateC2.AddExitTransition();
exitTransitionC2.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “TransitionNow”);
exitTransitionC2.duration = 0;
var stateMachineTransition = rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineC);
stateMachineTransition.AddCondition(UnityEditor.Animations.AnimatorConditionMode.If, 0, “GotoC”);
rootStateMachine.AddStateMachineTransition(stateMachineA, stateMachineB);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Creates the controller
var controller = UnityEditor . Animations . AnimatorController . CreateAnimatorControllerAtPath ( "Assets/Mecanim/StateMachineTransitions.controller" ) ;
// Add parameters
controller . AddParameter ( “ TransitionNow ” , UnityEditor . Animations . AnimatorControllerParameterType . Trigger ) ;
controller . AddParameter ( “ Reset ” , UnityEditor . Animations . AnimatorControllerParameterType . Trigger ) ;
controller . AddParameter ( “ GotoB1 ″ , UnityEditor . Animations . AnimatorControllerParameterType . Trigger ) ;
controller . AddParameter ( “ GotoC ” , UnityEditor . Animations . AnimatorControllerParameterType . Trigger ) ;
// Add StateMachines
var rootStateMachine = controller . layers [ 0 ] . stateMachine ;
var stateMachineA = rootStateMachine . AddStateMachine ( “ smA ” ) ;
var stateMachineB = rootStateMachine . AddStateMachine ( “ smB ” ) ;
var stateMachineC = stateMachineB . AddStateMachine ( “ smC ” ) ;
// Add States
var stateA1 = stateMachineA . AddState ( “ stateA1 ″ ) ;
var stateB1 = stateMachineB . AddState ( “ stateB1 ″ ) ;
var stateB2 = stateMachineB . AddState ( “ stateB2 ″ ) ;
stateMachineC . AddState ( “ stateC1 ″ ) ;
var stateC2 = stateMachineC . AddState ( “ stateC2 ″ ) ; // don’t add an entry transition, should entry to state by default
// Add Transitions
var exitTransition = stateA1 . AddExitTransition ( ) ;
exitTransition . AddCondition ( UnityEditor . Animations . AnimatorConditionMode . If , 0 , “ TransitionNow ” ) ;
exitTransition . duration = 0 ;
var resetTransition = stateMachineA . AddAnyStateTransition ( stateA1 ) ;
resetTransition . AddCondition ( UnityEditor . Animations . AnimatorConditionMode . If , 0 , “ Reset ” ) ;
resetTransition . duration = 0 ;
var transitionB1 = stateMachineB . AddEntryTransition ( stateB1 ) ;
transitionB1 . AddCondition ( UnityEditor . Animations . AnimatorConditionMode . If , 0 , “ GotoB1 ″ ) ;
stateMachineB . AddEntryTransition ( stateB2 ) ;
stateMachineC . defaultState = stateC2 ;
var exitTransitionC2 = stateC2 . AddExitTransition ( ) ;
exitTransitionC2 . AddCondition ( UnityEditor . Animations . AnimatorConditionMode . If , 0 , “ TransitionNow ” ) ;
exitTransitionC2 . duration = 0 ;
var stateMachineTransition = rootStateMachine . AddStateMachineTransition ( stateMachineA , stateMachineC ) ;
stateMachineTransition . AddCondition ( UnityEditor . Animations . AnimatorConditionMode . If , 0 , “ GotoC ” ) ;
rootStateMachine . AddStateMachineTransition ( stateMachineA , stateMachineB ) ;
|
翻译自: https://blogs.unity3d.com/2014/06/26/shiny-new-animation-features-in-unity-5-0/
unity 等待...动画