public void ChangeState(GameState newState)
        {
            if (!GameStates.Contains(newState) && newState != null)
            {
                throw new InvalidOperationException("You can only set Current property to a GameState instance that is attached to the StateMachine object.");
            }

            if (!Application.isPlaying)
            {
                _current = newState;
                return;
            }

            var previous = _current;

            if (previous != null)
            {
                previous.OnStateExit();
            }
            _current = newState;
            if (_current != null)
            {
                _current.OnStateEnter(previous);
            }
            if (OnCurrentStateChanged != null)
            {
                OnCurrentStateChanged(this, new StateChangedEventArgs(previous, _current));
            }
        }