- Home /
Is there any way to move a GUI.Button across the screen (when clicked) with a script?
To start off: I'm quite limited in programming. I have only started a few months ago, so please try to keep it relatively simple!
I have a GUI.Button (in a custom style), that when pressed, I want it to fly across and off the screen to the right. I've seen it somewhere before in games and I'm sure some of you know what I mean. I'm just not sure it's possible in Unity to manipulate buttons in this way. I was thinking along the lines of assigning the button to a variable and manipulating it that way, but so far I don't think I can.
Does anyone have any ideas?
Answer by Graham-Dunnett · Nov 22, 2012 at 11:04 PM
See http://docs.unity3d.com/Documentation/ScriptReference/GUI.Button.html.
The first argument to the GUI.Button call is a rectangle that says where on the screen the button is placed and how tall and wide it is. Just change the x value of the rectangle each frame and the button should move left or right.
Thankyou. With this reply I read the document and went searching for more answers and I put yours and another reply together to come up with something that works. Wouldn't have found it without you, so thanks.
I don't think that specific document is detailed very well, might just be me though.
Your answer
Follow this Question
Related Questions
Push GUI button, change another objects variable 2 Answers
Expecting variable error with a button 1 Answer
Adding an extra variable to GUI buttons? 2 Answers
3D Button? 1 Answer