public void ExecuteCoRoutineState(Func <IEnumerator> coRoutine, StopCoRoutineOnExitOptions options) { Func <StateMachine, IEnumerator> method = (sm) => { return(coRoutine()); }; ExecuteCoRoutineState(method, options); }
/// <summary> /// Sets the current GameState to a state that simply executes the specified co-routine. /// Note that the state will NOT automatically be changed after the co-routine finishes. If you want to change to a different state, /// you'll need to supply a co-routine that does that during the course of its operation. /// </summary> /// <param name="coRoutine">The co-routine to run. The method takes the current StateMachine as a parameter. </param> /// <param name="options">Options specifying which co-routines should be stopped when the state exits.</param> public void ExecuteCoRoutineState(Func <StateMachine, IEnumerator> coRoutine, StopCoRoutineOnExitOptions options) { var state = gameObject.AddComponent <CoRoutineState>(); state.CoRoutineDelegate = coRoutine; state.Options = options; Current = state; }