public void Awake() { states = new Dictionary <string, ICameraState>(); AddState("Action", new CameraActionState(this)); AddState("Lock", new CameraLockState(this)); current = Get("Action"); current.Enter(); }
// Use this for initialization public void Start() { if (current == null) //no states { throw new UnityException("STATE MACHINE IS EMPTY"); } current.Enter(); if (target == null) //no player selected { GameObject go = GameObject.FindGameObjectWithTag("Player"); if (go != null) { target = go.transform; return; } } }
private void Switch(string newStateName) { current.Exit(); current = states[newStateName]; current.Enter(); }