Running in a specific resolution - how?

Seems like an incredibly simple question, right? Well, why is this always such an ordeal?

Here’s what I want to do. I want to run my game in a certain resolution that I specify. In my case, I’m running it in Windows. So I modify my PlayerSettings to have a default screen width of 640 and a default screen height of 1136 (I’m simulating an iPhone 5’s resolution):

10544-unity_resolution.png

Then, I build and run my game, and… what? I’m presented with a bunch of possible resolutions I can run the game in, and none of them are the resolution I explicitly told Unity I wanted to run in, with absolutely no indication as to why.

I seem to be following a completely intuitive path that new users will follow when trying to get their game to run in a specific resolution, so why does it not work as expected?

Unity can’t create screen resolutions that your system doesn’t already support. It’s not an ordeal, it’s just a fact of life, since you won’t find any other games that can create their own screen resolutions either. If you don’t have a 640x1136 resolution (and it’s highly unlikely that you would), the only way to get Unity to use that particular resolution is to have your game run in windowed mode, and disallow the resolution dialog.

Hey, I ran into similar problem with you. And I found that this was simple to solve.
First disable the fullscreen mode in build settings, then add the following lines to your code:

void Start () {
	int width = 512; // or something else
	int height= 512; // or something else
	bool isFullScreen = false; // should be windowed to run in arbitrary resolution
	int desiredFPS = 60; // or something else

	Screen.SetResolution (width , height, isFullScreen, desiredFPS );
}

SImple and stupid solution = =