How to support multiple resolutions in 2D game

Hello,

I am somewhat new to Unity and Sprite Manager, so excuse me if this has been asked a million times, but I’ve searched quite a bit and found nothing. I have built a complete game (currently waiting approval) that was targeted at a single resolution. Now I want to support more than one device (it was the Nook) and I am having some issues: the graphics look blurry on the iPad.

Of course, that is only the tip of the iceberg. I want to support iphone 3g (1024x1024 max textures) up to ipad3 (gigormous resolution) but also including android phones/tablets. So I tried putting a very large texture and using mipmapping. That didn’t work: the image were blurry as well. (Note that I had at least planned the graphics properly: they are all at 17:10 aspect ratio to accomodate all the devices I could think of.) Btw, I am using Sprite Manager 2, but I believe what I am asking should be valid for any 2d game.

So how do people build a single app that can run on different devices? One project per size? I’m currently thinking of having 3 different atlases and swapping the UV coordinated and materials of the PackedSprite at launch, depending on the device.

But I was thinking that I can’t be the first one to have this problem, so here I come asking for help and guidance.

Alain-Daniel

Here is the approach I’m trying now: whenever I need a sprite (I only use PackedSprite), I create multiple version, one for each resolution (let’s say 3 here). Then, I turn the sprite into a prefab that I put in the Resources folder.

After that, in the object where I would have put the sprite normally, I place a SpriteSelector script. On start, that script determine which version of the prefab to instantiate and does so, as shown in the code below

public string lowResPrefab, highResPrefab;
   
   // Use this for initialization
   void Start () {
      string prefab;
      if( Camera.main.pixelWidth > Camera.main.pixelHeight )
         prefab = lowResPrefab;
      else 
         prefab = highResPrefab;
      
      GameObject go = Instantiate(Resources.Load(prefab)) as GameObject;
      go.name = prefab;
   }

My understanding is that since the prefab are not, per se, part of any object of the scene when it loads, that no textures associated with them will load. They should load when Resource.Load is called, right?

There are still a few things I am unsure of:

  • if a load a prefab multiple times, does its texture get loaded a single time or multiple? (I guess I can check that with the profiler)
  • using this setup, I don’t see the object in the editor. There must be a way to add some code to the SpriteSelector to allow it to show in the editor.

I’m sharing this in the hope that someone will have some feedback whether this is a good direction to be going in…