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
1
Question by Pandiux · Aug 18, 2012 at 10:31 PM · guiiosresolutionjoystickipad

Resolution Independent GUITexture?

Hey, so I'm making a game both for PC and iOS, (iPad, iPhone, iPod), but my problem is that I positioned Penelope's tutorial joysticks and they look correct on the unity editor, but once I export to my iPad with Retina it all goes very small and the joysticks end up in the lower left corner. They are still usable though. So how can I position a guitexture in the Unity Editor and make it to the same scale and position when exported to a different resolution such as iPad 3?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by OperationDogBird · Aug 18, 2012 at 10:40 PM

You will need to code the size manually based on the Screen.width and Screen.height values. This way you will have the same relative size no matter what the end resolution is.

 public var t:GUITexture;

 function Start()
 {
     t.pixelInset.width =0.1*Screen.width;
     t.pixelInset.height=0.1*Screen.width;
 }

I use Screen.width for both so the texture is a perfect square. This will make the texture 1/10 the size of screen width.

Comment
Add comment · 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
1

Answer by ScroodgeM · Aug 18, 2012 at 10:36 PM

  1. GUITexture's position in XY is screen-relative position. texture position will be 'sticked' to this point. for example, if you want to show a texture in screen's center, use X=0.5 Y=0.5. if in corner, X=0 or 1 Y=0 or 1 depends on which corner.

  2. GUITexture's size in pixels should be the same in any screen, so texture's real size depends on pixel's size. on iDevices with higher resolution pixels are smaller and your texture will looks smaller. cause almost all iDevices have small pixel size, just increase texture scale for iDevices build. Also, you could scale GUITexture to screen size with fixed divisor

Comment
Add comment · 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
0

Answer by pixel_fiend · Jun 30, 2014 at 07:11 PM

Using Screen.width is not future-proof. Instead, use Screen.dpi to detect the actual pixel density of the display.

Attach this script to any GUITextures you use in your game.

 void Start () {
 
         //check for retina display
         bool isRetina = Screen.dpi >= 150;
         if (isRetina) {
             // double pixelInset if we're using retina
             Rect pi = guiTexture.pixelInset;
             guiTexture.pixelInset = new Rect(pi.x*2, pi.y*2, pi.width*2, pi.height*2);
         }
 
     }
Comment
Add comment · 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

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

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting resolutions for iPad and iPhone 0 Answers

How do I set up my editor to "ipadview" 0 Answers

How do I make the size of GUI objects the same across all resolutions? 3 Answers

Dynamically choosing a high resolution texture at runtime on iOS devices 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 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