欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

协程执行顺序测试备份

程序员文章站 2022-07-04 09:45:22
...

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 () {
 
 }
}