示例#1
0
    public void SetAnimationSpeed(string animationName, float speed)
    {
        CachedLegacyAnimation[animationName].speed = speed;

        if (CachedLegacyAnimation.IsPlaying(animationName))
        {
            lastAnimationUpdateTime = GetNormalizedAnimationTime(animationName);
        }
    }
示例#2
0
    public void SetAnimationTime(string animationName, float time)
    {
        CachedLegacyAnimation[animationName].normalizedTime = time;

        if (CachedLegacyAnimation.IsPlaying(animationName))
        {
            lastAnimationUpdateTime = GetNormalizedAnimationTime(animationName);
        }
    }
 void StartLoadingAnimation(string anim_Loading)
 {
     if (CachedLegacyAnimation != null)
     {
         CachedLegacyAnimation.Play(anim_Loading);
     }
     else
     {
         Debug.LogWarning("Loading button: " + name + " has no attached animation.");
     }
 }
示例#4
0
    public void StopAllAnimations()
    {
        if (!string.IsNullOrEmpty(currentPlayingClipName))
        {
            StopAnimation(currentPlayingClipName, true);
        }

        CachedLegacyAnimation.Stop();
        currentPlayingClipName  = null;
        lastAnimationUpdateTime = 0f;
    }
示例#5
0
    public void StopAnimation(string animationName, bool sampleStop)
    {
        if (IsPlayingAnimation(animationName))
        {
            if (sampleStop)
            {
                SampleAnimation(animationName, 0f);
            }

            CachedLegacyAnimation.Stop(animationName);

            currentPlayingClipName  = null;
            lastAnimationUpdateTime = 0f;
        }
    }
示例#6
0
    public bool IsPlayingAnimation(string animation)
    {
        if (CachedLegacyAnimation.IsPlaying(animation))
        {
            if (animation != currentPlayingClipName)
            {
                Debug.LogWarning("Animation cached clip name is out of sync!");
                currentPlayingClipName = animation;
            }

            return(true);
        }

        return(false);
    }
示例#7
0
    public void SampleAnimation(string animationName, float sampleTime)
    {
        PlayAnimation(animationName);

        CachedLegacyAnimation[animationName].normalizedTime = sampleTime;
        CachedLegacyAnimation[animationName].enabled        = true;
        CachedLegacyAnimation.Sample();
        CachedLegacyAnimation[animationName].enabled = false;

        StopAnimation(animationName);

        if (!IsPlayingAnimation(animationName))
        {
            lastAnimationUpdateTime = sampleTime;
        }
    }
示例#8
0
    public void PlayAnimation(string animationName, bool continueFromCurrentTime)
    {
        if (IsPlayingAnimation(animationName))
        {
        }
        else
        {
            currentPlayingClipName     = animationName;
            CachedLegacyAnimation.clip = CachedLegacyAnimation.GetClip(animationName);
            CachedLegacyAnimation.Play(animationName);
        }

        if (!continueFromCurrentTime)
        {
            CachedLegacyAnimation[animationName].normalizedTime = 0f;
            lastAnimationUpdateTime = 0f;
        }
    }
示例#9
0
    void LateUpdate()
    {
        if (animationSubscriptions.Count == 0)
        {
            return;
        }

        bool endEvent = false;

        if (!CachedLegacyAnimation.isPlaying)
        {
            if (!string.IsNullOrEmpty(currentPlayingClipName))
            {
                endEvent = true;
            }
            else
            {
                return;
            }
        }

        if (!endEvent && !CachedLegacyAnimation.IsPlaying(currentPlayingClipName))
        {
            Debug.LogWarning("Clip name cache out of sync.");
            return;
        }

        float animationTime = GetNormalizedAnimationTime(currentPlayingClipName);

        TriggerEventsForTimeRange(lastAnimationUpdateTime, animationTime);

        lastAnimationUpdateTime = animationTime;

        if (endEvent)
        {
            currentPlayingClipName  = null;
            lastAnimationUpdateTime = 0f;
        }
    }