StartCoroutine from other MonoBehaviour is not working

by JamesB   Last Updated July 24, 2016 08:05 AM

I am trying to replicate the model of Unity documentation about coroutines, but I want to partition it in another class:

I have these two:

public class A: MonoBehaviour {

    void Start() {
        print("Starting " + Time.time);
        TesteWait teste = new TesteWait();
        print("Before WaitAndPrint Finishes " + Time.time);

public class B: MonoBehaviour {

    public IEnumerator WaitAndPrint(float waitTime) {
        yield return new WaitForSeconds(waitTime);
        print("WaitAndPrint " + Time.time);

It prints, ignoring the coroutine:

Starting 0 Before WaitAndPrint Finishes 0

The two methods work well in the same class.

Related Questions

Recursive serialization error?

Updated December 03, 2017 05:13 AM