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 Celsius · Mar 12, 2013 at 02:19 AM · positionvectorpositioningyx

X and Y positioning(buttons). How do they work and why does building the game change their positions?

Hi I made a quick game where the buttons are on the left hand side. I am trying to allign them with x and y positioning. The game is 800x600 and below is my co ordinates for the buttons:

 if (GUI.Button(new Rect(Screen.width/2+300, Screen.height/2-120, 80, 50), "Open Store!")){    
 GameObject.Find("maincontrol").GetComponent<inventory>().cash();
         }    
 }    
             
 if (GUI.Button(new Rect(Screen.width/2+300, Screen.height/2-60, 80, 50), "Display")){    
         GameObject.Find("maincontrol").GetComponent<fadeout>().fade();
         camera1.enabled = true;
         camera2.enabled = false;
         camera3.enabled = false;    
         }    
 if (GUI.Button(new Rect(Screen.width/2+300, Screen.height/2, 80, 50), "Town")){    
         GameObject.Find("maincontrol").GetComponent<fadeout>().fade();
         text1=false;
         camera1.enabled = false;
         camera2.enabled = true;
         camera3.enabled = false;
         instore=false;
         intown=true;
         intopfloor=false;
         }    
 if (GUI.Button(new Rect(Screen.width/2+300, Screen.height/2+60, 80, 50), "1st Floor")){    
         text1=false;
         camera1.enabled = false;
         camera2.enabled = false;
         camera3.enabled = true;
         instore=false;
         intown=false;
         intopfloor=true;
         }            
 }

please take note of only the rect positions. My goal is ideally having them on the right hand side alligned with the background. Here is my ideal position and one through trial and error I have obtained: This is from the built version of the game.

![IMG]http://i1159.photobucket.com/albums/p628/xLiemx/Capture2_zpsd41ee840.png[/IMG][1]

Now this is where the problem lies. In unity testing, the position of the buttons do not reflect the actual outcome when I built the game. In unity testing, the below image is where I had to place the buttons to get the desirable affect above.

![IMG]http://i1159.photobucket.com/albums/p628/xLiemx/capture1_zps9648ea86.png[/IMG][2]

Obviously I seem to not understand the new Rect(Screen.width/2+300, Screen.height/2-60, 80, 50) and would like help in..

  1. details on proper uses

  2. what my actual numbers should be. (please note this is a 800x600 game)

Any help is greatly appreciated. Essentially I'd like to understand so in future, when I use the position code on a 2d surface for buttons, the placement I do in unity testing will be the actual position for when I have built my game on a 800x600 scale.

[1]: http://i1159.photobucket.com/albums/p628/xLiemx/Capture2_zpsd41ee840.png

[2]: http://i1159.photobucket.com/albums/p628/xLiemx/capture1_zps9648ea86.png

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

10 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

Related Questions

How to create a GUI Text when reaching a point 1 Answer

Object position in relation to another object 1 Answer

How to get a vector3 (postion) 1 unit away from another in the direction of a 3rd vector3? 2 Answers

Offset position to a target 3 Answers

GUI position according to 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