Пример #1
0
    public async Task Show(bool show, bool skipTween, bool forcibly = false)
    {
        if (!forcibly && _isOpening == show)
        {
            return;
        }

        // Init tween
        if (_tween != null && _tween.IsActive() && _tween.IsPlaying())
        {
            return;
        }

        if (show)
        {
            _rectRoot.gameObject.SetActive(true);
        }

        _cgRoot.blocksRaycasts = false;

        float startAlpha = show ? 0.0f : 1.0f;
        float goalAlpha  = show ? 1.0f : 0.0f;
        float duration   = skipTween ? 0.0f : _duration;

        _tween = DOTween.To(
            () => startAlpha,
            (v) => {
            _cgRoot.alpha = v;
            startAlpha    = v;
        },
            goalAlpha, duration).SetUpdate(true);

        await _tween.AsyncWaitForCompletion();

        if (!show)
        {
            _rectRoot.gameObject.SetActive(false);
        }
        else
        {
            _cgRoot.blocksRaycasts = true;
        }

        _isOpening = show;
    }