// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public void EnterStates(State _toEnter, State _toExit) { currentStates.Add(_toEnter); if (machine != null && machine.logDebugInfo) { Debug.Log("FSM Debug: Enter State - " + _toEnter.name + " at " + Time.time); } if (_toEnter.onEnter != null) { _toEnter.onEnter(_toExit, _toEnter); } if (_toEnter.children.Count != 0) { if (_toEnter.mode == State.Mode.Exclusive) { if (_toEnter.initState != null) { _toEnter.EnterStates(_toEnter.initState, _toExit); } else { Debug.LogError("FSM error: can't find initial state in " + _toEnter.name); } } else // if ( _toEnter.mode == State.Mode.Parallel ) { for (int i = 0; i < _toEnter.children.Count; ++i) { _toEnter.EnterStates(_toEnter.children[i], _toExit); } } } }