Example #1
0
    public virtual void Hide(AT.Constant.CallBack callback = null)
    {
        if (this.gameObject.activeSelf == false)
        {
            return;
        }

        StartCoroutine(CoTweenHide(callback));
    }
Example #2
0
    public virtual void Show(AT.Constant.CallBack callback = null)
    {
        if (this.gameObject.activeSelf)
        {
            return;
        }

        gameObject.SetActive(true);
        StartCoroutine(CoTweenShow(callback));
    }
Example #3
0
    private IEnumerator CoTweenShow(AT.Constant.CallBack callback = null, float delay = 0f)
    {
        if (_showTweens.Count < 0)
        {
            yield break;
        }

        if (delay > 0f)
        {
            yield return(new WaitForSeconds(delay));
        }

        IsTweenPlaying = true;
        for (int index = 0; index < _showTweens.Count; index++)
        {
            _showTweens[index].ResetToBeginning();
            _showTweens[index].PlayForward();
        }

        yield return(null);

        while (IsTweenPlaying)
        {
            bool isPlaying = false;
            for (int index = 0; index < _showTweens.Count; index++)
            {
                if (_showTweens[index].isActiveAndEnabled == true)
                {
                    isPlaying = true;
                    break;
                }
            }

            if (isPlaying)
            {
                yield return(null);
            }
            else
            {
                IsTweenPlaying = false;
            }
        }

        callback?.Invoke();
        EventDelegate.Execute(_onShowCallbacks);
    }
Example #4
0
    private IEnumerator CoTweenHide(AT.Constant.CallBack callback = null, bool isPlayStartOnCurrent = true, float delay = 0f)
    {
        if (_hideTweens.Count < 0 && _reverseHideTweens.Count < 0)
        {
            gameObject.SetActive(false);
            yield break;
        }

        if (delay > 0f)
        {
            yield return(new WaitForSeconds(delay));
        }

        IsTweenPlaying = true;
        for (int index = 0; index < _hideTweens.Count; index++)
        {
            if (isPlayStartOnCurrent == false)
            {
                _hideTweens[index].ResetToBeginning();
            }

            _hideTweens[index].PlayForward();
        }

        for (int index = 0; index < _reverseHideTweens.Count; index++)
        {
            _reverseHideTweens[index].PlayReverse();
        }

        while (IsTweenPlaying)
        {
            bool isPlaying = false;
            for (int index = 0; index < _hideTweens.Count; index++)
            {
                if (_hideTweens[index].isActiveAndEnabled == true)
                {
                    isPlaying = true;
                    break;
                }
            }

            for (int index = 0; index < _reverseHideTweens.Count; index++)
            {
                if (isPlaying == true)
                {
                    break;
                }

                if (_reverseHideTweens[index].isActiveAndEnabled == true)
                {
                    isPlaying = true;
                    break;
                }
            }

            if (isPlaying)
            {
                yield return(null);
            }
            else
            {
                IsTweenPlaying = false;
            }
        }

        gameObject.SetActive(false);

        callback?.Invoke();
        EventDelegate.Execute(_onHideCallbacks);
    }