protected void DoPlay(Transition _transition, string _animName) { if (string.IsNullOrEmpty(_animName)) { anim.Stop(); curAnimName = null; return; } // NOTE: we will change transition's scale here AnimTransition animTrans = _transition as AnimTransition; AnimationState nextAnimationState = anim[_animName]; if (nextAnimationState && animTrans != null && nextAnimationState.speed != 0.0f) { animTrans.scale = 1.0f / nextAnimationState.speed; } // check if rewind if (_animName == curAnimName) { anim.Rewind(_animName); } // if (animTrans == null || animTrans.duration == 0.0f) { anim.Play(_animName); } else { // sync n-time if (animTrans.syncNormalizedTime) { AnimState lastState = _transition.source as AnimState; if (lastState != null) { nextAnimationState.normalizedTime = lastState.normalizedTime; } anim.Blend(lastState.curAnimName, 0.0f, animTrans.duration); anim.Blend(_animName, 1.0f, animTrans.duration); } else { anim.CrossFade(_animName, animTrans.duration); } } curAnimName = _animName; }
/// <summary> 声明状态的跳转 </summary> /// <param name="_targetState"> 目标状态 </param> /// <param name="_duration"> 动画过渡所需时间 </param> public AnimTransition to(AnimState _targetState, float _duration = 0.3f, bool _syncNTime = false) { AnimTransition transition = new AnimTransition() { source = this, target = _targetState, duration = _duration, syncNormalizedTime = _syncNTime, }; transitionList.Add(transition); return(transition); }
/// <summary> 声明状态的跳转 </summary> /// <param name="_targetState"> 目标状态 </param> /// <param name="_duration"> 动画过渡所需时间 </param> public AnimTransition to(AnimState _targetState, float _duration = 0.3f, bool _syncNTime = false) { AnimTransition transition = new AnimTransition() { source = this, target = _targetState, duration = _duration, syncNormalizedTime = _syncNTime, }; transitionList.Add (transition); return transition; }
public AnimTransition sync( AnimTransition _transitionToSync ) { syncWith = _transitionToSync; return this; }
public AnimTransition sync(AnimTransition _transitionToSync) { syncWith = _transitionToSync; return(this); }