Пример #1
0
        public void PlayAnimation(string clipName, bool forceOnce = false)
        {
            this.forceOnce = forceOnce;
            if (!HasAnimationClip(clipName))
            {
                throw new Exception("The clip " + clipName + " does not exist in the animation data");
            }
            PlayingGUID = Guid.NewGuid();
            PlayingClip = clipName;
            timer       = 0f;
            frameTime   = 1f / AnimationData.GetClipFPS(clipName);

            /*if (OnPlayingAnimation != null)
             * {
             *      OnPlayingAnimation(clipName);
             * }*/
            OnPlayingAnimation(clipName);
            if (forceOnce)
            {
                currentFrame = AnimationData.GoToNextFrame(clipName, currentFrame, WeaverAnimationData.WrapMode.Once);
            }
            else
            {
                currentFrame = AnimationData.GetStartingFrame(clipName);
            }
            if (currentFrame == -1)
            {
                //Debug.Log("FINISHED PLAYING ANIMATION_A = " + PlayingClip);
                PlayingGUID = default(Guid);
                string originalClip = PlayingClip;
                PlayingClip = null;
                if (onAnimationDone != null)
                {
                    onAnimationDone(originalClip);
                    onAnimationDone = null;
                }
            }
            else
            {
                SpriteRenderer.sprite = AnimationData.GetFrameFromClip(clipName, currentFrame);

                /*if (OnFrameChange != null)
                 * {
                 *      OnFrameChange(currentFrame);
                 * }*/
                OnPlayingFrame(currentFrame);
            }
        }