Example #1
0
        public virtual void EnterState(UIState parentState = null)
        {
            if (UIStateMachine.Instance.LockTransitions || _runningTasks > 0)
            {
                                #if Debugging
                Debug.Log("There are still running tasks. Unable to enter state " + Type + ".");
                                #endif
                return;
            }

            if (SubStateList != null && SubStateList.Count > 0)
            {
                _currentSubstateIndex = _initialSubstate;
            }

            if (_gameObject == null)
            {
                _gameObject = gameObject;
            }
            _gameObject.SetActive(true);

            if (onEnterStateStart != null)
            {
                onEnterStateStart();
            }
            UIStateMachine.Instance.EnterStateStart(Type);

            CurrentState = this;
            _parentState = parentState;
            OpenPanel();

            if (SubStateList != null && SubStateList.Count > 0)
            {
                StartEnteringSubState();
            }
        }