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 networkZombie · May 08, 2011 at 09:40 PM · guipositiongameresolution

GUI messes up depending on the screen resolution

I dont know why this happens but all my GUI texts, GUI textures etc are not where they are supposed to be when I change the screen resolution to something other than my default screen resolution. How do I fix this?

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 Joshua · May 08, 2011 at 09:48 PM

Please use search. This has been asker and answered a LOT of times before. Basically, instead of of setting the positions with an exact number like so

Gui.Button( Rect( x, y, width, height), text);

Make it relative to the default resolution. With default I mean the one you use to design it.

var defWidth : int; var defHeight : int;

function OnGUI () {

 var widthScale = Screen.width/defWidth;
 var heightScale = Screen.height/defHeight;

 Gui.Button( Rect( x*widthScale , y*heightScale , width*widthScale , height*heightScale ), text);

}

Comment
Add comment · Show 3 · 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 networkZombie · May 10, 2011 at 12:38 AM 0
Share

I dont have any buttons. just textures and texts

avatar image Joshua · May 10, 2011 at 06:33 AM 0
Share

The scaling idea remains the same. Just apply it to scale and position or to position and pixelInset.

avatar image jesusluvsyooh · Apr 01, 2012 at 05:11 PM 0
Share

thank you joshua, this has been the simplest and best way to do this I've come across

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

1 Person is following this question.

avatar image

Related Questions

GUI position and size in different screen resolutions 1 Answer

Is there a way to lock GUI buttons to a screen position insted of a pixel defined position so it will show up no matter the resolution of the screen? 0 Answers

Is it possible to move relative position of GUI? 0 Answers

GUI Label Size and Position Changes With Resolution 2 Answers

Different GUI Sizes in player and on mobile?? 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