协程执行顺序测试备份

阅读更多

using UnityEngine;
using System.Collections;

public class test1 : MonoBehaviour {

 // Use this for initialization
 void Start () {
        StartCoroutine(testc());
 }

    private IEnumerator testc()
    {
        Debug.Log("test enter");
        //fun();
        StartCoroutine(testc2());
        //yield return StartCoroutine(testc2());
        Debug.Log("test after fun");
        yield return new WaitForSeconds(1);
        Debug.Log("test over");
    }

    private void fun()
    {
        Debug.Log("fun enter");
        StartCoroutine(testc2());
        Debug.Log("fun over");
    }
    private IEnumerator testc2()
 {
        Debug.Log("test2 enter1");
        Debug.Log("test2 enter2");
        Debug.Log("test2 enter3");
        yield return new WaitForSeconds(2);
        Debug.Log("test2 over");
    }

 // Update is called once per frame
 void Update () {
 
 }
}

你可能感兴趣的:(协程执行顺序测试备份)