x


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,

more ▼

asked Dec 07 '10 at 11:57 AM

apple741 1 gravatar image

apple741 1
3 5 5 10

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.
}
else
{
   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.)

more ▼

answered Dec 07 '10 at 03:26 PM

Bampf gravatar image

Bampf
5.1k 8 20 49

That make sense :) Would it be bad for optimizations to also re-texture some of the regular elements with higer def textures through the same script? Even though I already have them textured both in the scene and my prefabs?

Dec 07 '10 at 09:35 PM apple741 1

I think the place I'd do it would be by having lores and hires prefabs. That way you could change anything: textures, model, or shaders. In the script that instantiates the prefab you'd use the same trick of having three variables to choose between the prefabs. But, I would only do this where it was really needed. Test without that, see how it looks.

Dec 08 '10 at 04:38 AM Bampf

Thank you very much :)

Dec 09 '10 at 12:27 AM apple741 1
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3892
x3570
x2014
x505
x492

asked: Dec 07 '10 at 11:57 AM

Seen: 5158 times

Last Updated: Dec 07 '10 at 12:26 PM