playMaker

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

MrStanaland

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
StartCoroutine and wait until finished
« on: May 23, 2014, 10:20:52 PM »

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.