UnityAsync icon indicating copy to clipboard operation
UnityAsync copied to clipboard

AsyncOperation await issue

Open maraudical opened this issue 2 years ago • 1 comments

when running the following code

List<DisplayInfo> displays = new List<DisplayInfo>();
Screen.GetDisplayLayout(displays);
DisplayInfo display = displays[1];
await Screen.MoveMainWindowTo(display, new Vector2Int(display.width / 2, display.height / 2));
Debug.Log("Finished");

The operation completes however the await call never continues on to call the Debug.Log. I have no clue why it is getting stuck but this may be a problem with MoveMainWindow method itself, I just wanted to share a bug I encountered.

maraudical avatar Aug 02 '23 20:08 maraudical

its odd because if I set it up like this

AsyncOperation op = Screen.MoveMainWindowTo(display, new Vector2Int(display.width / 2, display.height / 2));
await Await.Until(() => op.isDone);

It works

maraudical avatar Aug 02 '23 20:08 maraudical