- Home /
Notification of Game/Camera resize, in Editor.
I'm creating a script that will move objects based on the camera size (think anchoring interface elements to the corner of the screen). This script works fine at run-time. I wanted to extend the script to work in the editor so that I don't have to hit play to refresh positions.
I have a custom editor for the script I just mentioned. Inside the script's OnInspectorGUI(), I look for changes in the offset, and then update the position of the object if necessary. However, the problem lies in the Camera that I am referencing. For whatever reason, the Camera is reporting it's pixelWidth/pixelHeight as the dimensions of the "Inspector" window. This was frustrating, but I found a workaround tagging the script with [ExecuteInEditMode], and have a coroutine that gets fired from the custom editor script that will query the camera's (correct) pixelWidth/pixelHeight. It's a kludge, but the only way I can get valid camera pixel dimensions without having to hit 'play'.
However, issues come up if the 'Game' window is resized (and therefore the camera pixel dimensions change). Is there any way to get notified or regularly check if the 'Game' window gets resized?