protected IEnumerator CurrentAnimationCoroutine(bool isFirstRun) { // Trigger start event and wait for delay if (isFirstRun == true) { InvokeEventIfBound(AnimationStarted, this); if (StartDelay > 0.0f) { yield return(new WaitForSeconds(StartDelay)); } } // Animation body CurrentPercentage = 0.0f; CurrentValue = StartValue; startTime = Time.time; IsPlaying = true; while (CurrentPercentage < 1.0f) { float percentage = (Time.time - startTime) / PlayDuration; ProgressLerpAnimation(percentage); InvokeEventIfBound(AnimationUpdated, this, CurrentValue); yield return(new WaitForEndOfFrame()); } CurrentPercentage = 1.0f; // Loop? if (IsLoop == true) { InvokeEventIfBound(AnimationRlooped, this); StartNewCoroutine(ref CurrentAnimationEnumerator, CurrentAnimationCoroutine(true)); } else { IsPlaying = false; valueWrapper = new AnimationLerpWrapper <A>(); InvokeEventIfBound(AnimationEnded, this); } }
protected override void Update() { base.Update(); if ((UpdateMethod == EUpdateMethod.UPDATE) && (IsPlaying == true)) { if (CurrentPercentage < 1.0f) { float percentage = (Time.time - startTime) / PlayDuration; ProgressLerpAnimation(percentage); InvokeEventIfBound(AnimationUpdated, this, CurrentValue); } else { CurrentPercentage = 1.0f; // Loop? if (IsLoop == true) { InvokeEventIfBound(AnimationRlooped, this); CurrentPercentage = 0.0f; } else { IsPlaying = false; valueWrapper = new AnimationLerpWrapper <A>(); InvokeEventIfBound(AnimationEnded, this); } } } // Debug text if (logAnimationEvents == true) { LogCanvas("AnimationLerp", AnimationName + " - Is Running : " + IsPlaying + "\n" + "CurrentPercentage : " + CurrentPercentage + "\n" + "CurrentAlpha : " + CurrentAlpha); } }
public virtual void StartAnimation(ref AnimationLerpWrapper <A> animationLerpWrapper) { valueWrapper = animationLerpWrapper; StartAnimation(); }
public void StartAnimationFloat() { wrapperScale = new AnimationLerpWrapper <float>(); animationLerpFloat.StartAnimation(ref wrapperScale); }