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 JoshMBeyer · Sep 11, 2014 at 03:08 AM · guiresolutionscale

Simple GUI question.

I'm sure its an easy thing to do, but for some reason i forgot what I am doing wrong. How can I make it to where the gui doesnt go off screen when viewed in different resolutions? If I set it up to fit my game view in the editor, when its on my android its way too big and can't see half of the gui

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

Answer by Landern · Sep 11, 2014 at 04:30 AM

If using 4.6, use the Reference Resolution component.

if using < 4.6(old OnGUI system) you will want to use a ratio of the current screen resolution or modify the GUI.matrix.

links to the same question with answers:

http://answers.unity3d.com/questions/156619/scaling-the-gui-with-different-screen-resolutions.html

http://answers.unity3d.com/questions/150736/script-gui-units.html

http://answers.unity3d.com/questions/307330/gui-scale-guis-according-to-resolution.html

http://answers.unity3d.com/questions/156619/scaling-the-gui-with-different-screen-resolutions.html

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 MichaelARoberts · Sep 11, 2014 at 04:33 AM

You can either use a matrix (something I still haven't done) which is talked about here

or can use something like this code here. Shown in javascript but works the same way C#.

 #pragma strict
 
 function OnGUI ()
 {
 GUI.Box(Rect(Screen.width,Screen.height,0,0), "A Text Filled Box");
 }
 

by using Screen.width and Screen.height unity grabs the size of your screen and scales it accordingly.

Of course, in 4.6 Unity's GUI scales automatically (I believe, haven't used it all too much yet) with the new canvas system.

For further reading on the old GUI (the one you are probably using): click here

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 JoshMBeyer · Sep 11, 2014 at 05:15 AM 0
Share

Yes, tried that. But.. still doesnt work properly when having more than one item. Also if the font is large, it doesnt shrink with the screen

avatar image
0

Answer by theultimatepwn · Sep 11, 2014 at 05:57 AM

A little script that might help you,

 function OnGUI() {
     GUI.Box (new Rect((Screen.width / 2) - 100 , 0, 200, Screen.height), "Insert Random Text");
 }

Notice the Screen.width and Screen.Height, It is necessary in most cases for a nice GUI that is compatible with multiple platforms. But don't hold any of this against me, GUIs are not my strong point. Anyway.. Good luck to you with your game, I hope that I helped.

,I would suggest reading the documentation on GUIs in Unity, it helped me a lot when I first started doing GUIs. (GUI Scripting Guide)

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

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

Related Questions

GUI Resolution Ajust 1 Answer

Scaling GUI correctly according to game window resolution? 1 Answer

How do I Scale a GUITexture or GUIText for different resolutions screen sizes on the iPhone? 1 Answer

Android GUI resize problem 1 Answer

Bulletproof way to do resolution independant GUI scaling? 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