startcoroutine
时间: 2023-08-18 15:09:37 浏览: 56
StartCoroutine是Unity中的一个方法,用于启动协程。协程是一种特殊的函数,可以通过yield语句将程序挂起,暂停程序执行,并在程序恢复执行时继续执行后续的代码。\[2\]在给定的代码示例中,StartCoroutine方法被用于启动一个名为Coroutine的协程方法。在该协程方法中,首先输出"Log 111111",然后通过yield语句暂停程序执行。在等待一定时间后(1秒钟),协程会继续执行,并输出"Log 222222"。\[2\]此外,你还可以自定义协程暂停方法,通过继承CustomYieldInstruction类并重写keepWaiting方法来实现。在给定的代码示例中,自定义的MyYieldInstruction类被用于在点击鼠标左键后恢复执行协程。\[3\]
#### 引用[.reference_title]
- *1* *2* *3* [【Unity知识点详解】StartCoroutine、CustomYieldInstruction详解](https://blog.csdn.net/huoyixian/article/details/129091436)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)