Exemple #1
0
    public void SetAnimationTime(string animationName, float time)
    {
        CachedLegacyAnimation[animationName].normalizedTime = time;

        if (CachedLegacyAnimation.IsPlaying(animationName))
        {
            lastAnimationUpdateTime = GetNormalizedAnimationTime(animationName);
        }
    }
Exemple #2
0
    public void SetAnimationSpeed(string animationName, float speed)
    {
        CachedLegacyAnimation[animationName].speed = speed;

        if (CachedLegacyAnimation.IsPlaying(animationName))
        {
            lastAnimationUpdateTime = GetNormalizedAnimationTime(animationName);
        }
    }
Exemple #3
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);
    }
Exemple #4
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;
        }
    }