“收益率0"与“收益率0"之间有什么区别?和"yield return null".在协程中? [英] What is the difference between "yield return 0" and "yield return null" in Coroutine?

查看:137
本文介绍了“收益率0"与“收益率0"之间有什么区别?和"yield return null".在协程中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,对"yield"有点困惑.但是最后我了解了如何使用WaitForSeconds

I'm new and a bit confused about "yield". But finally I understand how it worked using WaitForSeconds

但是我看不到"yield return 0"和"yield return null"之间的区别.

but I can't see the difference between of "yield return 0" and "yield return null".

他们都在等待下一帧执行吗?

are both them waiting for the next frame to execute?

对不起,我的英语不好.非常感谢.

sorry for my bad English. Thank you very much.

推荐答案

yield return 0yield return null都产生单个帧.最大的区别是yield return 0分配内存是因为0在装箱过程中发生装箱和拆箱,但是yield return null不会分配内存.因此,强烈建议您使用yield return null来关注性能.

Both yield return 0 and yield return null yields for a single frame. The biggest difference is that yield return 0 allocates memory because of boxing and unboxing of the 0 that happens under the hood, but yield return null does not allocate memory. Because of this, it is highly recommended to use yield return null if you care about performance.

这篇关于“收益率0"与“收益率0"之间有什么区别?和"yield return null".在协程中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆