YieldReturn

The YieldReturn node is used in coroutines to convert the yield instruction to an IEnumerator, which controls the behaviour of the coroutine.

 

Examples

In this example, the Program will log ‘First” at start. It then wait until 5 seconds and then log ‘Finished’.

Flow Graph:

Generated Script:

using UnityEngine;
using System.Collections.Generic;

public class Program : MonoBehaviour {

  public void Start() {
    base.StartCoroutine(Coroutine());
  }

  public System.Collections.IEnumerator Coroutine() {
    Debug.Log("First");
    yield return new WaitForSeconds(5F);
    Debug.Log("Finished");
  }
}

 

Output:

First
Finished
Was this helpful to you?

Leave a Reply

Your email address will not be published. Required fields are marked *