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 Tyler 2 · Feb 23, 2011 at 01:03 AM · guiresolution

Resolution question?

Hello. I have a problem with my game's resolution(I think). My current aspect ratio inside the Unity editor is 3:2, my GUI elements are all laid out in their correct positions and they look fine. But, because I used fixed positions rather than screen width/2, screen height/2 + ###, etc. to place the GUI stuff, when I go to another resolution, it is messed up. I was told by someone that I could save myself alot of work and just add this script and Unity would automatically scale my GUI elements correctly. But, I am having some trouble understanding what they meant. Where would I place this bit of code? Would it be in the OnGUI function?

Here is what they said (and here is the original question I asked).

there's another very smooth method to do this and doesn't require you to recalculate the absolute position for every gui element. You can set the transform matrix for gui elements with GUI.matrix. So if you do this:

Vetor3 scale = new Vector3(origWidth /Screen.width, origHeight /
Screen.height, 1); GUI.matrix =Matrix4x4.Scale(scale);

where origWidth and origHeight is the screen size you used when designing the gui you can design you gui in the editor, using a good screen size (e.g. 1920x1200) using absolute positions like you would normally do. Then all you have to do is tell the script the original used screen size and will do the scaling for you. No extra code needed.

Thanks

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

0 Replies

· Add your reply
  • Sort: 

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

GUIs Do Not Decrease With Resolution 1 Answer

Make GUI Image one size? 1 Answer

GUI.matrix - invalid matrix 2 Answers

Placing GUI elements? 1 Answer

GUI messes up depending on the screen resolution 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