Esempio n. 1
0
        public void Show()
        {
            if (gameObject.activeSelf)
            {
                return;
            }
            gameObject.SetActive(true);

            OnOpenStart?.Invoke();
            OnOpenFinish?.Invoke();
        }
Esempio n. 2
0
        public void SetInitialVisibility(bool visible)
        {
            if (_initialized)
            {
                throw new InvalidOperationException();
            }

            _initialized = true;
            _state       = visible ? State.Opened : State.Closed;

            _canvasGroup.alpha        = visible ? 1 : 0;
            _canvasGroup.interactable = visible;

            _animator.Play(AnimatorHashes.GetStateHash(_state));
            _animator.SetBool(AnimatorHashes.GetParameterHash(Param.IsOpened), visible);
            _animator.Update(0f);

            _animator.GetBehaviour <UIHolderStateMachineBehaviour>().OnStateEntered += state => {
                _state = state;
                switch (_state)
                {
                case State.Open:
                    _canvasGroup.alpha = 1;
                    OnOpenStart?.Invoke();
                    break;

                case State.Opened:
                    _canvasGroup.interactable = true;
                    OnOpenFinish?.Invoke();
                    break;

                case State.Close:
                    _canvasGroup.interactable = false;
                    OnHideStart?.Invoke();
                    break;

                case State.Closed:
                    _canvasGroup.alpha = 0;
                    OnHideFinish?.Invoke();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            };
        }