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 luis1992 · Jun 12, 2013 at 05:03 PM · androidiosmobileongui

Mobile OnGUI

Hi, there. I recently started to develop games for mobile platforms but I have some GUI size problem according to different screen sizes. This is a pretty common topic, but I could not figure out a suitable solution. I am using: GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3 (horizRatio, vertRatio, 1));

When I implemented all my textures, labels .I used set float rather than Screen.height. However, my problem is that the texture will stretch/compress to fit the screen and have a different shape. I thought the function will keep the original shape but just scale up, but it doesn't. Here I have a few questions: 1, Did I have a wrong native resolution so that it does match different screens? 2. What is the best way to fit all 16:9(android), 4:3(ipad), and 3:2 (iphone) ?

Thank you very much. Any direct or suggestions provide I'd greatly appreciated.

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
0

Answer by Mehrdad995 · Jul 29, 2013 at 12:04 PM

Hi I couldn't understand very well if you mean you want to save the original shape of your GUI do this:

 var myGuiTexture : GUITexture
 
 function OnGUI(){
 myGuiTexture.pixelInset.width = 0.05*Screen.width;
 myGuiTexture.pixelInset.height = 0.05*Screen.width;
 // this will keep the size of your GUI 0.05 of the screen size which depend on screen width 
 //so you can change the 0.05 to anything 
 //in order to save the original shape you want
 }

Hope this helped :)

Comment
Add comment · Show 1 · 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 luis1992 · Jul 31, 2013 at 10:24 AM 1
Share

Thanks for the help. But I solved my problem with this : scaleFactor = (float)Screen.width / (float) referenceResolutionWidth; Then just multiple this to every textures.

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

15 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 avatar image avatar image avatar image avatar image

Related Questions

Is it possible to send SMS from an action in Unity? (Mobile iOS or Android) 1 Answer

Native list views on Mobile? 0 Answers

Unity 5 mobile single stick control 6 Answers

Is GameObject.FindWithTag Bad for Mobile Platforming? 1 Answer

Mecanim for Mobile Devices 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