コード例 #1
0
        void Init()
        {
            if (m_IsInited)
            {
                return;
            }

            int count = Tweens.Length;

            for (int i = 0; i < count; i++)
            {
                CocoTweenBase tween = Tweens [i];
                if (!tween.enabled)
                {
                    continue;
                }

                tween.startAutomatically = false;
                tween.tweenTime          = showTime;
                tween.tweenWrapMode      = WrapMode.ClampForever;
                tween.Init(showedOnStart);
            }

            m_Status = showedOnStart ? Status.Showed : Status.Hided;

            m_IsInited = true;
        }
コード例 #2
0
        void ShowOrHide(bool show, System.Action endAction)
        {
            Init();

            Status targetStatus = show ? Status.Showed : Status.Hided;

            // already be target status
            if (m_Status == targetStatus)
            {
                if (endAction != null)
                {
                    endAction();
                }
                return;
            }

            // cancel last tween
            LeanTween.cancel(gameObject);

            // end action
            int usedFlags = 0;

            System.Action <int> tweenEndAction = (flag) => {
                usedFlags &= (~flag);
                if (usedFlags == 0)
                {
                    m_Status = targetStatus;
                    if (endAction != null)
                    {
                        endAction();
                    }
                }
            };

            // start tween
            m_Status = show ? Status.Appear : Status.Disappear;
            int count = Tweens.Length;

            if (count > 32)
            {
                count = 32;
            }

            for (int i = 0; i < count; i++)
            {
                CocoTweenBase tween = Tweens [i];
                if (!tween.enabled)
                {
                    continue;
                }

                int flag = 1 << i;
                usedFlags |= flag;
                bool canRun = tween.TweenOnce(!show, false, () => {
                    tweenEndAction(flag);
                });

                if (!canRun)
                {
                    usedFlags &= ~flag;
                }
            }

            // all unused
            if (usedFlags == 0)
            {
                m_Status = targetStatus;
                if (endAction != null)
                {
                    endAction();
                }
            }
        }