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 Nat20 · Jan 29, 2014 at 03:20 AM · guiscaleguitext

How do I build a GUI that works on different sized screens?

I've been struggling getting Guitext /Guitextures to scale to screen (both for different PC monitors as well as Android Phone Sizes). Could someone please explain to me step by step (or point me to previously made instructions) the basics of building a GUI that works on different screen sizes/aspect ratios.

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
0
Best Answer

Answer by Domo23000 · Jan 29, 2014 at 03:58 AM

Try this

GUI.box(Rect( Screen.width/2, Screen.height/2, Screen.width, Screen.height), "Words");

Screen.width measures the width of the screen, and Screen.height does the same but with the height.

for the position, id Screen.width/2 to position it in the center. and the size i just use Screen.width to measure the width and set the size to that.

Comment
Add comment · Show 6 · 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 Infinite_Gamer · Jan 29, 2014 at 04:29 AM 0
Share

I have been having the same problem too.I tried the above script and it does not work for me.It puts the box in the lower right hand corner.

avatar image Domo23000 · Jan 29, 2014 at 04:34 AM 0
Share

I am doing something like this so i will test it and make it work

avatar image Domo23000 · Jan 29, 2014 at 04:40 AM 0
Share
 Screen.width/2 - Screen.width/2

This worked for the position.

avatar image Infinite_Gamer · Jan 29, 2014 at 04:46 AM 0
Share

Ok I might have been doing something wrong then...Sorry that I questioned your answer.

avatar image Domo23000 · Jan 29, 2014 at 04:52 AM 0
Share

oh, no I did it wrong, I didn't add ( - Screen.width/2 ) after Screen.width and Screen.height. And don't be sorry, your question helped me fix the answer. :D

Show more comments
avatar image
0

Answer by Phenelo · Jan 29, 2014 at 05:12 AM

I'm also a newbie and what I did is I set up an original resolution and used the method here about modifying GUI matrix. Once your settled, draw the GUI's in fixed positions like:

 GUI.Box(new Rect(10,10,100,50), "Hey!");

And it will be scaled depending on the GUI matrix if the resolution changed. I think resizing your Game View window to the closest size of your original resolution helps, because it worked for me.

EDIT: SIDE NOTE OnGUI and GUITexture/GUIText are two different Unity GUI Systems.

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 Ashish Dwivedi · Jan 30, 2014 at 12:52 PM

You have to calculate your rect by using "Screen.width" and "Screen.height"

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

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

Related Questions

How to make GUI Text Scale to different Resolutions? 3 Answers

What's wrong with my function? It keeps telling me 'loseText' is not a member of 'UnityEngine.GUIText'. Please help, please and thank you! 0 Answers

Scaling a GUI element to fit it's contents 0 Answers

Problem With GUI Circle Thickness 1 Answer

Fix Blurry UI text? 10 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