- Home /
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--
Further to this: I have been thinking about this all day, and (setting aside the possibility of saving and loading texture atlases based on resolution which seems like a problematic thing to cope with) I think that there are the following options:
1) $$anonymous$$ake a separate version for Retina and non-Retina displays
2) Scale the sprites programatically
3) For each (logical) scene in the game, have an actual scene for each target resolution, which is loaded based on the users device. There are also two versions of each packed sprite prefab. A prefab is either included in the scene (offscreen) or instantiated in the Awake() method and the correct one loaded for the scene
4) As above, but with a single empty scene - and all prefabs instantiated in the Awake() method.
5) Redo all graphics, deploy to the smaller resolution size, and then the Retina devices should display these ok, albeit more blocky
6) Say screw it, mark down to experience, deploy this app for Retina devices only, and NEXT time start design for the non-retina devices…
So, taking these in turn:
1) I have read elsewhere on this forum that Apple no longer allows HD versions of the same app…. can anyone verify this?
2) Looks veering degrees of c**p, dependent on filtering, mipmaps etc… but none are very nice!
3), 4) Both these will increase the download size, but am I correct in saying that unloaded scenes and prefabs do not take up memory at runtime (i.e. the memory footprint at any one time is the current scene and it's assets?)
5) Is this the way most people do it? Just design for the lower spec and let it 'go blocky' on the trine devices?
6) I would like to know the proportion of Retina to non-Retina owners… how many potential customers am I losing?
Any thoughts or discussion on this would be appreciated; remember that I am using Sprite$$anonymous$$anager2, so I can't load textures directly!
Hi $$anonymous$$ike,
I have the same problem as you. I've just started looking at a Unity project I started over a year ago pre iPhone 4. Sprite$$anonymous$$anager is great, but all my sprites were created with the iPhone 3 resolution in $$anonymous$$d. Running pixel perfect on the iPhone 4 results in very tiny sprites! I've got a very simple game for children that only has three scenes and I had resigned myself to just having an HD version of each scene and HD versions of all my sprites (there aren't that many). It's not a very efficient way of doing it, and it probably isn't a suitable approach for a larger game - in fact, you've stated this in option 3... didn't read that!
The problem I have is that I've not found a way of automatically detecting what device the game is running on. I was going to have a GUI menu, but noticed in your question you were able to detect the device in code. Can I ask how you did this?
$$anonymous$$any thanks, Judy
Answer by mikeyj21 · Sep 17, 2011 at 07:13 PM
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 480*320, not 960*640). 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--
Thanks $$anonymous$$ike, that's very helpful advice. I appreciate you taking the time to reply in such detail. Hope you sorted out the other problem and still have hair! Judy x
Your answer
Follow this Question
Related Questions
apple rejected app due to iphone & iPad resolution mismatch 1 Answer
Force *only* iPhone 4 to 480x320 resolution 0 Answers
iOS Target Resolution doesn't seem to affect resolution 0 Answers
Unity Screen.SetResolution gives me black screen on iPhone 4S 1 Answer
How do you account for iPhoneSettings.generation not working in the Editor? 2 Answers