Updating UI in Editor mode while Application is paused

So I have a very specific issue, which I have been battling with for several hours.

I am trying to create a tool that automatically makes screenshots in different resolutions of your game. The tool works fine, while the game is in playmode. However, it takes a screenshot once per frame, so if objects are moving every frame, every screenshot will be slightly different.

My solution was to pause the Unity editor (EditorApplication.isPaused = true). However, now when I resize the GameView window, my UI does not update. This only happens when I go the next frame manually.

How to reproduce:

  • Create a Canvas with an image anchored to the top right.
  • Press Play, then Pause.
  • Resize the GameView.

You will see how the GameView resizes, but the image does not stay in the corner. If you press ‘Next Frame’, it will also resize the UI. My question is, how can I make the UI resize in the same frame?

Things I tried:

  • Canvas.ForceUpdateCanvases ();
  • SceneView.RepaintAll ();
  • Using Reflection to literally call every method on the GameView EditorWindow
  • Calling Update, LateUpdate on every single GameObject in my Canvas (using BroadcastMessage)

It seems like the resizing of the UI happens in a magical place to which I have no access. Any Unity Editor experts who can shed some light on this issue?

See pdf for more info[59160-ui-update-issue.pdf|59160]


Little late :frowning: but I’ve got the same issue.

In my case calling the camera.Render() function fixed the problem.

The issue you are facing is related to how the Unity Editor updates its UI while in pause mode. When the Editor is paused, it does not update the UI in real-time, but instead waits until the next frame to do so. This means that any changes to the UI made during pause mode will only be updated on the next frame, which is why your image is not staying in the corner when you resize the GameView window.

Unfortunately, there is no easy solution to this proble[205942-13537967732d4590aa40fd75fad4b507-compressed-a92dd5.pdf|205942]w and your UI, and then use this window to take screenshots instead of the regular GameView. This way, you can control the update of the UI in real-time and take screenshots at the exact moment you want.

Alternatively, you could try using the OnRenderImage function to capture screenshots instead of taking them every frame. This function is called after the scene has been rendered and can be used to capture the current frame as an image. By using this function, you can capture a screenshot at a specific point in time, regardless of any movement or changes in the scene.

Overall, this is a challenging problem that requires a deep understanding of how the Unity Editor works. You may want to consult with other Unity experts or seek help from the Unity community to find a solution that works for your specific use case.