What is the correct way to programatically set the screen resolution?

I would like to allow the user to switch resolutions in the web player. I’ve created a script that makes the following call:

Screen.SetResolution(width, height, false);

and wired that up to an NGUI button. When I hit the button, the screen flickers, but the resolution stays the same. I know this because not only does it look the same, but I’m printing out Screen.currentResolution, and it reads 1920x1080, both before and after.

Why isn’t this call working?

Update:

I just verified that the same code works when I run as a Win32 app, though it seems that Screen.currentResolution is wrong. The app changes size, but the resolution still reads 1920x1080, so currentResolution must refer to my desktop resolution. How can I print the app’s actual resolution?

If it’s via the web player, why not just set the resolution of the window in your html rather than unity.

And depending on how you have your web player set up in html, that might be your problem. Unity is unable to make your resolution bigger if the html is forcing it to be a specific resolution.