void OnDisable()
        {
            if (mTweeners != null)
            {
                switch (m_DisableMode)
                {
                case eDisableMode.Pause:
                    for (int i = 0, imax = mTweeners.Length; i < imax; i++)
                    {
                        TweenerBase tween = mTweeners[i];
                        if (tween != null)
                        {
                            tween.Pause();
                        }
                    }
                    break;

                case eDisableMode.Stop:
                    for (int i = 0, imax = mTweeners.Length; i < imax; i++)
                    {
                        TweenerBase tween = mTweeners[i];
                        if (tween != null)
                        {
                            tween.Stop();
                            tween.Reset();
                        }
                    }
                    break;
                }
            }
        }
        public bool StopTween(int i, bool reset)
        {
            if (mTweeners == null)
            {
                return(false);
            }
            if (i < 0 || i >= m_Tweens.Length)
            {
                return(false);
            }
            TweenData   tween   = m_Tweens[i];
            int         ti      = (int)tween.tweenType;
            TweenerBase tweener = mTweeners[ti];

            if (tweener == null)
            {
                return(false);
            }
            tweener.Stop();
            if (reset)
            {
                tweener.Reset();
            }
            return(true);
        }
        public void PlayTween(int i, System.Action onFinish)
        {
            if (i < 0 || i >= m_Tweens.Length)
            {
                return;
            }
            if (mTweeners == null)
            {
                mTweeners = new TweenerBase[TweenTypeMax + 1];
            }
            TweenData   tween   = m_Tweens[i];
            int         ti      = (int)tween.tweenType;
            TweenerBase tweener = mTweeners[ti];

            if (tweener != null)
            {
                tweener.Stop();
            }
            PlayTweenData(tween);

            if (onFinish != null)
            {
                tweener = mTweeners[ti];
                if (tweener != null && tweener.Playing)
                {
                    tweener.OnFinishEvent += onFinish;
                }
                else
                {
                    try { onFinish(); } catch (System.Exception e) { Debug.LogException(e); }
                }
            }
        }
        void OnEnable()
        {
            int  count       = m_Tweens.Length;
            bool firstEnable = mEnableCount++ <= 0;
            bool playMode    = true;

            switch (m_DisableMode)
            {
            case eDisableMode.None:
                if (!firstEnable)
                {
                    return;
                }
                break;

            case eDisableMode.Pause:
                playMode = firstEnable;
                break;
            }
            if (playMode)
            {
                for (int i = 0; i < count; i++)
                {
                    if (!m_Tweens[i].autoPlay)
                    {
                        continue;
                    }
                    PlayTween(i, null);
                }
            }
            else if (mTweeners != null)
            {
                for (int i = 0, imax = mTweeners.Length; i < imax; i++)
                {
                    TweenerBase tween = mTweeners[i];
                    if (tween != null)
                    {
                        tween.Resume();
                    }
                }
            }
        }
Example #5
0
        public static void CacheTweener(TweenerBase tweener)
        {
            if (tweener == null)
            {
                return;
            }
            int index = GetTweenerIndex(tweener.GetType());

            tweener.Clear();
            if (cached_tweeners == null)
            {
                int capacity = 16;
                if (index >= capacity)
                {
                    index--;
                    index |= index >> 1;
                    index |= index >> 2;
                    index |= index >> 4;
                    index |= index >> 8;
                    index |= index >> 16;
                    index++;
                    capacity = index;
                }
                cached_tweeners = new List <Queue <TweenerBase> >(16);
            }
            while (index >= cached_tweeners.Count)
            {
                cached_tweeners.Add(null);
            }
            Queue <TweenerBase> queue = cached_tweeners[index];

            if (queue == null)
            {
                queue = new Queue <TweenerBase>();
                cached_tweeners[index] = queue;
            }
            queue.Enqueue(tweener);
        }
 public void StopGroup(string group, bool reset)
 {
     for (int i = 0, imax = m_Tweens.Length; i < imax; i++)
     {
         TweenData tween = m_Tweens[i];
         if (string.IsNullOrEmpty(tween.group))
         {
             continue;
         }
         if (group != tween.group)
         {
             continue;
         }
         TweenerBase tweener = mTweeners[(int)tween.tweenType];
         if (tweener != null)
         {
             tweener.Stop();
             if (reset)
             {
                 tweener.Reset();
             }
         }
     }
 }