示例#1
0
        private void ValidateState()
        {
            if (!_isStarted)
            {
                return;
            }

            _tween?.Kill();
            _tween = null;

            var popupCanvasGroup = Popup.GetComponent <CanvasGroup>();

            switch (ActivatableState)
            {
            case ActivatableState.Active:
                popupCanvasGroup.interactable = true;
                popupCanvasGroup.alpha        = 1;
                Popup.localScale = Vector3.one;
                Blend.color      = new Color(0, 0, 0, 0.5f);
                break;

            case ActivatableState.Inactive:
                popupCanvasGroup.interactable = false;
                popupCanvasGroup.alpha        = 0;
                Popup.localScale = Vector3.one * 0.1f;
                Blend.color      = Color.clear;
                break;

            case ActivatableState.ToActive:
                _tween = DOTween.Sequence()
                         .Append(Popup.DOScale(Vector3.one, 1f).SetEase(Ease.OutBack))
                         .Join(Blend.DOFade(0.5f, 0.5f))
                         .Join(popupCanvasGroup.DOFade(1, 0.3f))
                         .OnComplete(() =>
                {
                    _tween = null;
                    popupCanvasGroup.interactable = true;
                    ActivatableState = ActivatableState.Active;
                });
                break;

            case ActivatableState.ToInactive:
                popupCanvasGroup.interactable = false;
                _tween = DOTween.Sequence()
                         .Append(Popup.DOScale(Vector3.one * 0.1f, 1f).SetEase(Ease.InBack))
                         .Join(DOTween.Sequence()
                               .Append(Blend.DOFade(0, 0.5f))
                               .Join(popupCanvasGroup.DOFade(0, 0.3f).SetDelay(0.2f))
                               .SetDelay(0.5f))
                         .OnComplete(() =>
                {
                    _tween           = null;
                    ActivatableState = ActivatableState.Inactive;
                });
                break;
            }
        }