- Home /
In a play mode test, does 'yield return null' block until the end of the next frame?
..that seems to be what it's doing. I wrote this test here: https://github.com/stevesan/solid_unity/blob/master/Assets/ExamplePlayerTest.cs#L18
And it works. So it makes me think that when I yield a null, I don't get control back until the END of the next frame, which seems like it's fine. But hopefully it's not just some random time during the next frame?
A simple way to test :
void Start()
{
StartCoroutine( Coroutine() ) ;
}
void IEnumerator Coroutine()
{
while( true )
{
Debug.Log( Time.frameCount ) ;
yield return null ;
}
}
You should see in the console 1 .. 2 .. 3 .. 4 .. 5 ..
and so on prooving that yield return null
blocks until the next frame (after the Update
, but before rendering)
Answer by PizzaPie · Jul 08, 2018 at 02:35 PM
Event Execution Order This should clear things out.
I see - it is indeed after all Update's of the NEXT frame. cool thanks. feel free to post an answer if ya want the points :)
Your answer
Follow this Question
Related Questions
Testing Network Code in Unity 4 Answers
Testing in Unity3d 4 Answers
How to use the Unity Remote on Android? 0 Answers
Mock Collision Object in Unity 0 Answers
Test for lower specs 0 Answers