2d iOS game: different resolutions question.

Hi!

I have read loads of posts on the subject of assets on different target iOS devices, and I still don’t understand the best way forward!

I have nearly completed my 2d masterpiece (he jokes!), but I didn’t expect there to be so such a problem regarding deploying onto different target resolutions; I designed all my many sprites with the iPhone 4 display in mind, expecting them to scale nicely since the 3GS has half the resolution and thus a 1:2 pixel ratio.

Note that I am using SpriteManager2 with an Orthographic camera!

My first attempt involved setting Unity to the iPhone Wide (480x320) setting in the editor from iPhone4G Wide (960x640). I detected the iPhone version in script, and set the localScale of each packed sprite to 0.5 for non Retina displays.

This looks horrible (I expected the 1:2 pixel ratio between the 4G and 3GS to mean it would scale nicely!)

So, I experimented with using MipMaps on the texture atlas (which I had disabled previously as sprites were ‘pixel perfect’) with combinations of the various filter modes and MipMap filtering, and even tried different Ansio levels (despite the fact that to my understanding, Ansio is about viewing textures from an angle).

Everything still looks got was horrible, but now with added blurriness!

So, having read many different opinions on this on the forums; what is the recommended method of dealing with this?
I have heard approaches ranging from a duplicate scene with duplicate assets through to using scaling, through to deploying multiple versions of the app…

I understand that there is always a tradeoff, but surely there is an established method to this?

Any guidance would be much appreciated!

–Mike–

Hi Judy,

Sorry for the delay in replying - I have had another issue which has had me tearing my hair out!

There are two ways you can detect which version:

The way i do it is this (I shall explain WHY later):

function Running960(){
	return Screen.width==960; //so it works in the editor
}

function Running1024(){
	return Screen.width==1024;
}

So, any time I need to do something different depending on device, I just use it like this:

If (Running1024){
  // do stuff for iPad
}
else if (Running960){
 //do stuff for iPhone4
}
else{
 //do stuff for 3GS or lower
}

The other way is using the iPhoneSettings.generation method… something like this:

function TouchGen() {
	if( iPhoneSettings.generation == iPhoneGeneration.iPhone || iPhoneSettings.generation == iPhoneGeneration.iPhone3G ||iPhoneSettings.generation == iPhoneGeneration.iPhone3GS ||iPhoneSettings.generation == iPhoneGeneration.iPodTouch2Gen || iPhoneSettings.generation == iPhoneGeneration.iPodTouch3Gen || iPhoneSettings.generation == iPhoneGeneration.iPodTouch4Gen)
	{
    	//480*480
    	return 1;
	}
	else if( iPhoneSettings.generation == iPhoneGeneration.iPhone4 )
	{
    	//960*640
    	return 2;
	}
	else if( iPhoneSettings.generation == iPhoneGeneration.iPad1Gen || iPhoneSettings.generation == iPhoneGeneration.iPad2Gen )
	{
    	//1024*768
    	return 3;
	}

	else
	{
    	//Unknown device or are you in the editor?
    	return editorGeneration;
	}

}

The reason I use two different methods is this:
It is possible to set the iPhone4 to work in Standard resolution (in PlayerSettings->Configuration->Target Resolution) rather than it’s native resolution, so if you use the iPhoneSettings.generation to detect which device you are running on, then you will not actually be able to determine from this what screen size you have.
(As running in Standard resolution on an iPhone4 will give you 480320, not 960640).
However, the Touch locations of the device are not changed when changing the resolution, so you need the iPhoneSettings.generation method to correctly detect user input.

Hope that makes sense!

Actually, I have just realised: if you change the Target Resolution as I describe above, this will probably fix your problem with the pre iPhone4 sprites you designed…

To be honest though, I never found a way of making my Retina designed sprites (i.e. those I designed for the iPhone4) look good running on a non-Retina device… so I just bit the bullet and made two versions of each scene, and had two versions of each sprite!

Hope this helps!

–Mike–