playMaker

Author Topic: StartCoroutine and wait until finished  (Read 6189 times)

MrStanaland

  • Playmaker Newbie
  • *
  • Posts: 3
StartCoroutine and wait until finished
« on: May 24, 2014, 01:20:52 AM »

To let my FSM's wait for a long running task, I've attached a modified version of the StartCoroutine action with a new boolean that let's you decide whether FINISH is called at the start or end of your coroutine.

The magic is a wrapper coroutine that yields until the underlying coroutine completes before calling the Finish function:

Code: [Select]
IEnumerator CoroutineWrapper() {
    yield return DoStartCoroutine();
    Finish();
}


Note: I didn't modify the OnExit, but StopCoroutine *might* need to be called on the wrapper when the waitForFinish is selected.