Beispiel #1
0
        /// <summary>
        /// Plays the animation clip with specified name from the beginning.
        /// </summary>
        /// <param name="name">The name of animation clip</param>
        public void Play(string name, float startTime = 0)
        {
            UiAnimationClip clip = GetAnimationClipByName(name);

            if (clip != null)
            {
                Play(clip, startTime);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Plays the specified animation clip from the beginning.
        /// </summary>
        /// <param name="animation">Animation clip</param>
        public void Play(UiAnimationClip animation, float startTime = 0)
        {
            if (IsPlaying)
            {
                Stop();
            }

            _activeAnimation = animation;

            if (_activeAnimation != null)
            {
                IsPlaying = true;
                Time      = startTime;

                _activeAnimation.RewindToBegin();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Stops all playing animation clips that were started with this UiAnimation.
        /// </summary>
        public void Stop(bool gotoLastFrame = true)
        {
            if (!IsPlaying || _activeAnimation == null)
            {
                return;
            }

            if (gotoLastFrame)
            {
                _activeAnimation.RewindToEnd();
            }

            OnComplete.InvokeIfNotNull(_activeAnimation);

            IsPlaying = false;
            Time      = 0;

            _activeAnimation = null;
        }