public void ChangeState(int state, object[] extraArgs) { if (CurrentState == state) { return; } CurrentState = state; if (StateHandler != null) { StateHandler.Dispose(); StateHandler = null; } StateHandler = StateFactory.Create(state, extraArgs); StateHandler.Initialize(); }
// Use this for initialization void Start() { stateInstance = Instantiate(stateHandler) as StateHandler; stateHandler.Initialize(Exit); }