- Home /
Programmatically change the Game Window resolution
Hello!
I've been looking for a way to either programmatically change the resolution of the game window or add/change the predefined resolutions. So the resolution I want to be able to set, instead of having to manually resize with "Free Aspect", are the ones shown as eg. "Screen: 1136*640" when showing "Stats".
Any clues on how to accomplish this? Is it even possible? Cheers!
Answer by PAEvenson · Jun 28, 2013 at 02:51 PM
Perhaps this is what youre looking for?
http://docs.unity3d.com/Documentation/ScriptReference/Screen.SetResolution.html
Thanks for the reply!
What I'm trying to do is an editor tool where I can specify a resolution, for example 1136 * 640, press apply, and the game window resolution would be set. I did try that using Screen.SetResoulution( x, y, false ) but it had no effect.
*edit. Or, as I mentioned, be able to add custom resolutions to the predefined resolutions.
The SetResolution will work, but only in the actual build. To set your editor window resolution you need to go to Edit->Project Settings->Player and go to the resolution tab. You can specify the default resolution, which will be the Standalone option in your game window.
If you are trying to make a unity editor to quickly test custom resolutions you can access the player settings here: http://docs.unity3d.com/Documentation/ScriptReference/PlayerSettings.html
If you are trying to add custom resolutions to the Resolution dialog, I found my best solution was to create my own custom resolution dialog GUI that gets shown on startup.
Hope this helps...
Thanks again PAEvenson!
Would upvote if I had karma enough :)
Answer by Wanzyee · Jul 23, 2016 at 09:00 PM
Hi @Thingummywut, If you're still looking for it, you may take a look at my doc. And the script below~~ feel free to try it. link text