Detect resolution selected in Editor Game view?

Is there a way to know what resolution option is selected in the Game view, either during play or edit mode within the editor? I have some code that attempts to detect different iOS resolutions, which works great on the devices, but doesn’t works so well in the editor when the game view resolution is not set exactly. It would be helpful if I could get the name of the resolution selected, such as “iPad Wide (1024x768)”, or whatever.

A good question, but the answer seems a bit lacking. I thought I would elaborate on what finally works for me.

I can’t detect what option is selected, but I can reliably detect current GameView resolution (therefore its aspect ratio) and its changes.

  1. GameView resolution can be queried at any time by asking the main camera for Camera.pixelWidth and Camera.pixelHeight, while resetting its viewport rectangle (Camera.rect) to full size. Screen.width/height in editor are not actually fine; they return the size of the currently focused EditorWindow.

  2. Any MonoBehaviour can listen to GameView resolution changes if set to [ExecuteInEditMode]. OnGUI() then reports the new resolution that can be compared against the old one you need to remember. Note that the resolution is not yet updated in Update().

This is true for Unity 4.5.

I found a simple solution by calculating the aspect ratio instead of looking at the width and height directly. If I assume that iPhone resolution is always 2:3 or 3:2, then I can reasonably detect whether the game view is set to iPhone. Thanks for everyone else’s input.