Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by apple741 1 · Dec 07, 2010 at 11:57 AM · javascriptiphonegraphicsoptimization

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,

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Bampf · Dec 07, 2010 at 03:26 PM

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.)

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image apple741 1 · Dec 07, 2010 at 09:35 PM 0
Share

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?

avatar image Bampf · Dec 08, 2010 at 04:38 AM 0
Share

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.

avatar image apple741 1 · Dec 09, 2010 at 12:27 AM 0
Share

Thank you very much :)

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Whats the best way to setup a screen like this... 0 Answers

Pitfalls for characer/animations on the iPhone 1 Answer

Make objects easier to select 1 Answer

How to 'flick' objects in a 2d game 1 Answer

Can I stop a lerp completely when it gets to 20% of its original value? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges