Using Coroutines in Actions (1.8.1)
Note the coroutine is actually run by the PlayMakerFSM that owns the action.
C# Example:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: |
using UnityEngine; using System.Collections; namespace HutongGames.PlayMaker.Actions { [ActionCategory("Test")] public class CoroutineTestAction : FsmStateAction { [RequiredField] public FsmFloat time; private Coroutine routine; public override void Reset() { time = 5f; } public override void OnEnter() { routine = StartCoroutine(DoWait()); } private IEnumerator DoWait() { yield return new WaitForSeconds(time.Value); Log("Finished!"); Finish(); } public override void OnExit() { StopCoroutine(routine); } } } |