/// <summary> /// Starts Animation from objects current state to new /// </summary> /// <param name="targetState"> /// Target animation state <see cref="blindGUIAnimationState"/> /// </param> /// <param name="animationTime"> /// Duration of animation <see cref="System.Single"/> /// </param> /// <param name="animationCompleteDelegate"> /// This function will be called after animation is finished <see cref="AnimationCompleteDelegate"/> /// </param> /// <param name="easeType"> /// Animation Ease type <see cref="iTweenInBlindGUI.EaseType"/> /// </param> /// <param name="delay"> /// Delay of animation <see cref="System.Single"/> /// </param> public void AnimateTo(blindGUIAnimationState targetState, float animationTime, AnimationCompleteDelegate animationCompleteDelegate, iTweenInBlindGUI.EaseType easeType, float delay) { m_animationCompleteDelegate = animationCompleteDelegate; m_animationTime = animationTime; m_startAnimationState = new blindGUIAnimationState(this); m_finishAnimationState = targetState; //iTweenInBlindGUI.StopByName(this.name+"_animation"); iTweenInBlindGUI.ValueTo(this.gameObject, iTweenInBlindGUI.Hash( "name", this.name + "_animation", "time", m_animationTime, "delay", delay, "from", 0, "to", 1, "easetype", easeType, "onupdate", "AnimationStep", "oncomplete", "AnimationFinished")); }
void HandleAnimation(float deltaTime) { LoopMode loopMode; if (_overrideLoopMode) { loopMode = _overriddenLoopMode; } else { loopMode = currentAnimation.loopMode; } int numFrames = currentAnimation.frames.Count; _currentFrameTime += (deltaTime * _animationTimeScale); if (_currentFrameTime > currentAnimation.frames[currentFrameNumber].animTime) { // ---------------------------------------------------------------------- // LOOP // ---------------------------------------------------------------------- if (loopMode == LoopMode.Loops && numFrames > 1) { if (currentFrameNumber == numFrames - 1) { SetAnimationFrame(0); } else { SetAnimationFrame(currentFrameNumber + 1); } } // ---------------------------------------------------------------------- // PLAY ONCE // ---------------------------------------------------------------------- else if (loopMode == LoopMode.PlayOnce && !_playOnceAnimFinished) { if (currentFrameNumber < numFrames - 1) { SetAnimationFrame(currentFrameNumber + 1); } else if (currentFrameNumber == numFrames - 1) { _playOnceAnimFinished = true; if (_animCompleteCallback != null) { _animCompleteCallback(); _animCompleteCallback = null; } } } // ---------------------------------------------------------------------- // PING PONG // ---------------------------------------------------------------------- else if (loopMode == LoopMode.PingPong && numFrames > 1) { // ---------------------------------------------------------------------- // FORWARD // ---------------------------------------------------------------------- if (_pingPongForward) { if (currentFrameNumber < numFrames - 1) { SetAnimationFrame(currentFrameNumber + 1); } else { SetAnimationFrame(currentFrameNumber - 1); _pingPongForward = false; } } // ---------------------------------------------------------------------- // REVERSE // ---------------------------------------------------------------------- else { if (currentFrameNumber > 0) { SetAnimationFrame(currentFrameNumber - 1); } else { SetAnimationFrame(currentFrameNumber + 1); _pingPongForward = true; } } } // ---------------------------------------------------------------------- // RANDOM FRAME // ---------------------------------------------------------------------- else if (loopMode == LoopMode.RandomFrame && numFrames > 1) { int newFrame = Random.Range(0, currentAnimation.frames.Count); while (newFrame == currentFrameNumber) { newFrame = Random.Range(0, currentAnimation.frames.Count); } SetAnimationFrame(newFrame); } _currentFrameTime = 0.0f; } }
public void SetAnimCompleteCallback(AnimationCompleteDelegate callback) { _animCompleteCallback = callback; }
/// <summary> /// Starts Animation from objects current state to new /// </summary> /// <param name="targetState"> /// Target animation state <see cref="blindGUIAnimationState"/> /// </param> /// <param name="animationTime"> /// Duration of animation <see cref="System.Single"/> /// </param> /// <param name="animationCompleteDelegate"> /// This function will be called after animation is finished <see cref="AnimationCompleteDelegate"/> /// </param> public void AnimateTo(blindGUIAnimationState targetState, float animationTime, AnimationCompleteDelegate animationCompleteDelegate) { AnimateTo(targetState, animationTime, animationCompleteDelegate, iTweenInBlindGUI.EaseType.linear, 0.0f); }
/// <summary> /// Starts Animation from objects current state to new /// </summary> /// <param name="targetState"> /// Target animation state <see cref="blindGUIAnimationState"/> /// </param> /// <param name="animationTime"> /// Duration of animation <see cref="System.Single"/> /// </param> /// <param name="animationCompleteDelegate"> /// This function will be called after animation is finished <see cref="AnimationCompleteDelegate"/> /// </param> /// <param name="easeType"> /// Animation Ease type <see cref="iTweenInBlindGUI.EaseType"/> /// </param> /// <param name="delay"> /// Delay of animation <see cref="System.Single"/> /// </param> public void AnimateTo( blindGUIAnimationState targetState, float animationTime, AnimationCompleteDelegate animationCompleteDelegate, iTweenInBlindGUI.EaseType easeType, float delay ) { m_animationCompleteDelegate = animationCompleteDelegate; m_animationTime = animationTime; m_startAnimationState = new blindGUIAnimationState( this ); m_finishAnimationState = targetState; //iTweenInBlindGUI.StopByName(this.name+"_animation"); iTweenInBlindGUI.ValueTo( this.gameObject, iTweenInBlindGUI.Hash( "name", this.name+"_animation", "time", m_animationTime, "delay", delay, "from", 0, "to", 1, "easetype", easeType, "onupdate", "AnimationStep", "oncomplete", "AnimationFinished")); }
/// <summary> /// Starts Animation from objects current state to new /// </summary> /// <param name="targetState"> /// Target animation state <see cref="blindGUIAnimationState"/> /// </param> /// <param name="animationTime"> /// Duration of animation <see cref="System.Single"/> /// </param> /// <param name="animationCompleteDelegate"> /// This function will be called after animation is finished <see cref="AnimationCompleteDelegate"/> /// </param> public void AnimateTo( blindGUIAnimationState targetState, float animationTime, AnimationCompleteDelegate animationCompleteDelegate ) { AnimateTo(targetState, animationTime, animationCompleteDelegate, iTweenInBlindGUI.EaseType.linear, 0.0f); }
void HandleAnimation(float deltaTime) { LoopMode loopMode; if(_overrideLoopMode) loopMode = _overriddenLoopMode; else loopMode = currentAnimation.loopMode; int numFrames = currentAnimation.frames.Count; _currentFrameTime += (deltaTime * _animationTimeScale); if(_currentFrameTime > currentAnimation.frames[currentFrameNumber].animTime) { // ---------------------------------------------------------------------- // LOOP // ---------------------------------------------------------------------- if(loopMode == LoopMode.Loops && numFrames > 1) { if(currentFrameNumber == numFrames - 1) SetAnimationFrame(0); else SetAnimationFrame(currentFrameNumber + 1); } // ---------------------------------------------------------------------- // PLAY ONCE // ---------------------------------------------------------------------- else if(loopMode == LoopMode.PlayOnce && !_playOnceAnimFinished) { if(currentFrameNumber < numFrames - 1) { SetAnimationFrame(currentFrameNumber + 1); } else if(currentFrameNumber == numFrames - 1) { _playOnceAnimFinished = true; if(_animCompleteCallback != null) { _animCompleteCallback(); _animCompleteCallback = null; } } } // ---------------------------------------------------------------------- // PING PONG // ---------------------------------------------------------------------- else if(loopMode == LoopMode.PingPong && numFrames > 1) { // ---------------------------------------------------------------------- // FORWARD // ---------------------------------------------------------------------- if(_pingPongForward) { if(currentFrameNumber < numFrames - 1) { SetAnimationFrame(currentFrameNumber + 1); } else { SetAnimationFrame(currentFrameNumber - 1); _pingPongForward = false; } } // ---------------------------------------------------------------------- // REVERSE // ---------------------------------------------------------------------- else { if(currentFrameNumber > 0) { SetAnimationFrame(currentFrameNumber - 1); } else { SetAnimationFrame(currentFrameNumber + 1); _pingPongForward = true; } } } // ---------------------------------------------------------------------- // RANDOM FRAME // ---------------------------------------------------------------------- else if(loopMode == LoopMode.RandomFrame && numFrames > 1) { int newFrame = Random.Range(0, currentAnimation.frames.Count); while(newFrame == currentFrameNumber) newFrame = Random.Range(0, currentAnimation.frames.Count); SetAnimationFrame(newFrame); } _currentFrameTime = 0.0f; } }