示例#1
0
        private void Update()
        {
            if (!IsPlaying)
            {
                return;
            }

            timer += Time.deltaTime;
            if (timer > currentAnimation.GetDuration(frameIndex))
            {
                timer = 0;
                ++frameIndex;

                if (frameIndex > currentAnimation.Frames.Length - 1)
                {
                    if (currentAnimation.Loop)
                    {
                        frameIndex = 0;
                    }
                    else
                    {
                        --frameIndex;
                        IsPlaying = false;
                    }
                }
                renderer.sprite = currentAnimation.Frames[frameIndex].Sprite;
            }
        }