• 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 incitement · Aug 26, 2010 at 12:04 PM · guibuttonresolutionrelative

Button and resolution problem

Hello I have a big problem. button change place after a build the project and change the resolution. in unity i work with 1200 * 700 resolution (( 16/9 )) but when a change other resolution or make it iu full screen the button change place. not the same when i put it in unity project. how can i fix that . thanks

Comment
Add comment · Show 1
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 Wolfram · Aug 26, 2010 at 01:18 PM 0
Share

Jeez, I with people would learn how to use the SEARCH field. This question is asked about once a month!

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by StephanK · Aug 26, 2010 at 12:35 PM

GUI positions are absolute meaning that they will change their relative position if the screen size changes. To make them relative you need to calculate your Rectangles using factors. eg.:

void OnGUI () { public float x, y, width, height; Rect pos; pos.x = x * Screen.width; pos.y = y * Screen.height; pos.width = width * Screen.width; pos.height = height * Screen.height;

GUI.Button(pos, "test"); }

With x, y, width and height being values between 0...1 this should lead to relative positioning.

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 incitement · Aug 26, 2010 at 02:48 PM 0
Share

How can i apply this script. i have many button in my game . should i integrate this script with script of all the button or how. thanks

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Make GUI Button's size fit texture? 2 Answers

GUI Buttons scaling with resolution - help 2 Answers

Rotate GUI Button slowly 1 Answer

Button in GUI BeginScrollView problem 0 Answers

How to make button stay the same size on all screens? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges