I’m using a plugin that allocates some d3d resources (plugin not written by me).
Plugin lets me invalidate these resources before toggling full screen, and re-creating them after the toggle is done. This works fine when I’m in control of the toggle.
There are three scenarios where I run into problems (but the cause is basically the same):
-
After Alt-Tabbing out of application, the D3D device is lost, and when trying to Alt-Tab in again, Unity cannot reset the device so it hangs.
-
Unity reacts to Alt-Enter keyboard shortcut by toggling full screen without giving me any notification (that I know of). Since it cannot reset the D3D device, it crashes.
-
When running in windowed mode, dragging the window also apparently resets the d3d device. Again, a problem and a crash.
Is there a way for me to get notified of these situations by Unity so I can release the resources that are preventing the device from resetting?
We do have OnPreRender(), OnPostRender(), OnApplicationPause() and stuff.
Is there something like OnScreenChange()?