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

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

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