unity [yield return null] and [yield return WaitForSecond]

unity 协程

返回值IEnumerator
代码来自[company]

	IEnumerator _wait_one_frame_(System.Action onEntered, bool playEffects , bool blockScreen) {
    
    
		yield return null;
		//yield return new WaitForSeconds(2f);
		//yield return new WaitForEndOfFrame();

		InternalEnterScreen(onEntered, playEffects, blockScreen);	
	}

yield return null;
代表下一帧执行,调用顺序在Update后,LateUpdate前

yield return WaitForEndOfFrame();
WaitForEndOfFrame会在一帧结束后调用,且在LateUpdate之后调用。

yield return new WaitForSeconds(2f);
代表2秒后执行

原文链接

猜你喜欢

转载自blog.csdn.net/weixin_44238530/article/details/121188109