How to support Retina display

Hi guys,

I'm really unsure how to support the retina graphics on an iPhone 4. At the moment I already have my scene setup and textured in Unity (3.1) and all my prefabs textured so all I do is instantiate them and they are ready to go.

The problem is if its in iPhone 4 what would be the best/easiest way to re-texture everything if a retina supporting device is detected?

Thanks guys for your time,

There's a good chance your 3d objects will look okay, unless you have seriously been cutting your textures to the bone, to the minimum resolution you can get away with.

Most retexturing work for the retina display centers on making 2D elements (UnityGUI; GUITexture & GUIText) look good.

Here's one way to do it. In my GUI-related scripts I declare many of the GUIStyle's, Font's and Texture2D's three times:

private GUIStyle promptStyle;
public GUIStyle promptStyleLg;  // assign in inspector
public GUIStyle promptStyleSm;  // assign in inspector

private Texture2D icon;
public Texture2D iconLg;  // assign in inspector
public Texture2D iconSm;  // assign in inspector

Then in the script's Start() function I check whether the screen is large (indicating retina or iPad).

if ( MyUtil.ScreenIsLarge() )
   promptStyle = promptStyleLg;
   icon = iconLg;
   // etc.
   promptStyle = promptStyleSm;
   icon = iconSm;
   // etc.

In some cases I instead have a single texture that looks good on the retina display, and just calculate the Rect bounds differently.

private Rect rectButton;
public Rect rectButtonLg;  // assign in inspector
public Rect rectButtonSm;  // assign in inspector

Once I've got these set up, the rest of the script uses the private, "size-less" variables that were initialized by Start. (Note: while debugging I usually make them public so I can try different values in the editor and see how they look; then I copy what works into the corresponding "Lg" and "Sm" variables. I then make the "size-less" variables private. This catches any cases where I forgot to assign them to a sized variable in the Start method.)

Note that my game is not particularly GUI-heavy. So this work was tedious, but not excessive.

(Instead of declaring three variables each time, you could use an array of three elements. I didn't try that, but it would let you add additional sizes in future, and you might be able to build editor or runtime utilities around it.)