using System.Collections
public class Animator_Magic_2 : StateMachineBehaviour
{
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfo.normalizedTime >= 1)
{
//动画结束;
}
}
}
你需要获取当前animator所处在的动画状态,即使它处于idel状态也应当播放idel动画,你可以获取当前动画控制器处于哪个动画状态,正在播放哪些动画剪辑AnimatoranimAnimationInfo[]AnimationInfoArrvoidGetCurrentAnimationName(){anim=GetComponentltAnimator()AnimationInfoArr=anim.GetCurrentAnimationClipState(0)foreach(AnimationInfoainAnimationInfoArr){Debug.Log(a.clip.name)}}在 Build Settings 面板里有 Run in Background 的选项,选上了游戏才会在后台运行,否则游戏窗口转到后台时是不更新游戏逻辑的。在程序中用 Application.runInBackground (bool 类型)来判断是否在后台运行。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)