“收益率0"与“收益率0"之间有什么区别?和"yield return null".在协程中? [英] What is the difference between "yield return 0" and "yield return null" in Coroutine?
问题描述
我是新手,对"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 0
和yield 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屋!