Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
2
Question by danidu93 · Mar 02, 2016 at 05:14 PM · c#script.scripting beginnervectorrect

Change button position using script

Hi guys, I am creating a quizz and i dont know how to change position of button. I want to do this because i dont want that answer which are displayed on button shows always in the same order. So can you give me an example of how change 2 Button position for example we have ButtonAnswer1 ButtonAnswer2 and ButtonChangePosition. What i want is when you click on ButtonChangePosition the position of ButtonAnswer1 change with the position of ButtonAnswer2.

Ps:I know i have to use Vector and i saw in other post they write a code "Rect" but i dont know how to use those command and the documentation doesn't help me so please don't send me a link to a tutorial , if you can just show me the code for the example i give to you it would be very nice and it will help me alot . #thanks #HaveAniceDay #SorryForMyBadEnglish

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

2 Replies

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

Answer by Magius96 · Mar 02, 2016 at 05:24 PM

I have a better idea. Instead of changing the positions of the buttons, why not change the values that the buttons represent? From what I read of your question it sounds like you are really just trying to swap the buttons, which can be easier done by swapping what they represent instead.

That is unless you are hard coding the buttons, which is what it sounds like you are doing. In which case have to pose the question, "Can you think of no better way?"

Moving Buttons

Remember that the buttons are GameObjects, and every gameobject has a position vector in its transform. So if your button is named ButtonA, then in your code you want to get a reference to that.

 GameObject buttonA = GameObject.Find("ButtonA");

Once you have a reference to the button, you can proceed in moving it. So let's imagine that we want to move ButtonA 10 units left.

 Vector3 pos = buttonA.transform.position;
 pos.X -= 10f;
 buttonA.transform.position = pos;
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 black0001 · May 14, 2019 at 06:54 PM 0
Share

how to change the text on button ... i have 8 buttons and 1 buttons will have the answer of a question ... i want to change the position but not changing on which way i want to ... now how to change that text

avatar image
0

Answer by danidu93 · Mar 02, 2016 at 05:57 PM

Wow thank you very much for your answer your explication is very very good about how to move button . I already tryed to think another ways as you said.But it didnt works . Value of button every time changed but when i clicked on them it always show me "Wrong" (becaus i also have a hidden text which is enable when you press on a button and it show "True" if the answer is good or "Wrong" if not.Code was also very long and i get lost :/

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

126 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Need to Change this script function , please 0 Answers

Could someone translate these to c#? 1 Answer

Having transitions between two VideoPlayers triggered by clicking "x" times in a text layer 0 Answers

How to convert string to runnable code? 0 Answers

How to enable and disable back game object for ui button after a few seconds? 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