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 Youngapprentice · Dec 16, 2010 at 11:44 PM · guiresolutionscale

Scaling GUI When Screen Width is Adjusted

Hi, all! I have looked at the answers to this question many times, but none ever seem to work!

I have made I game. I have designed the GUI to work with 1080 x 1024 resolution screens. My GUI will get squished together or will leave the screen in any other resolution. Is there a way to scale my GUI so that the smaller the screen is, the smaller the GUI (& text inside it) is? The other examples I have seen just position the GUI. :(

Also, I have GUITexture backgrounds. Is there any way for me to make it so that my background image is scaled/stretched to fit the screen?

I really need help here. Any help would be greatly appreciated. Thanks! - YA

Comment
Add comment · Show 2
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 Uriel_96 · Dec 17, 2010 at 12:00 AM 0
Share

maybe you have not seen the correct answer so maybe this is the answer of your problem: http://answers.unity3d.com/questions/21244/gui-postion-affacted-when-$$anonymous$$imize-the-screen/27855#27855

avatar image Statement · Dec 17, 2010 at 12:09 AM 0
Share

Or maybe not. It doesn't address scaling. The author in that post want to change pixelInset, probably wanting to maintain pixel perfect scale and ins$$anonymous$$d position the elements around.

1 Reply

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

Answer by Statement · Dec 17, 2010 at 12:00 AM

Yes, you can use GUI.matrix to scale your Gui. However, note that your gui will probably look stretched with other aspect ratios unless you design your gui for each ratio.

Scale x by (Screen.width / 1080) and y by (Screen.height / 1024). Use Matrix4x4.Scale to create the matrix.

I haven't tested it myself but this should work.

Vector3 scale = new Vector3((float)Screen.width / 1080.0f, 
                            (float)Screen.height / 1024.0f, 
                            1.0f);
GUI.matrix = Matrix4x4.Scale(scale);
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

No one has followed this question yet.

Related Questions

Simple GUI question. 3 Answers

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


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