wait until condition is true

Hi there,
in my game, I set the GUI size and even game board sizes based on screen resolution. First, I set the screen resolution to the maximum resolution possible. It works, but I don’t know when the resolution switch is completed so I wait for 2 seconds to be sure which results in flicker.

Screen.SetResolution(Screen.resolutions[Screen.resolutions.Length-1].width,Screen.resolutions[Screen.resolutions.Length-1].height,true);
yield WaitForSeconds(2);
camera.orthographicSize=Screen.height/2;

Is there a way to wait until the screen resolution matches the max screen res?

What I could do is check for the resolution in the update(function and then call a separate funcio n that calculates the GUI sizes but since we can’t do anything as we wait for the resolution switch, i’d prefer to just wait)

Have you tried putting your code in a co-routine function ?

You may have something like :
yield changeRes ();

while changeRes would change the resolution, and loop until it’s changed.