示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        public virtual void StartAnimation(ref AnimationLerpWrapper <A> animationLerpWrapper)
        {
            valueWrapper = animationLerpWrapper;

            StartAnimation();
        }
示例#4
0
 public void StartAnimationFloat()
 {
     wrapperScale = new AnimationLerpWrapper <float>();
     animationLerpFloat.StartAnimation(ref wrapperScale);
 }