- Home /
Question by
ayrton_adiong · Jan 19, 2014 at 09:22 AM ·
guimovetag
How do I make many object move when I click a GUI button? I want the objects move upward.
How do I make many object move when I click a GUI button? I want the objects move upward.
Comment
Answer by getyour411 · Jan 19, 2014 at 09:31 AM
Assume you have a list of gameObjects, assume C# and upward is Y
OnGUI () {
// if button is pressed, do something:
if (GUI.Button(new Rect(x,y,w,h),"ClickMe")) {
doSomething()
}
}
private void doSomething() {
for(loop through GameObject list) {
Vector3 newPos = myList[loop_index].gameobject.transform.position;
myList[loop_index].gameObject.transform.position = new Vector3 (newPos, newPos+10, newpos);
}
}
Your answer
Follow this Question
Related Questions
Why is this Raycast not working ? 3 Answers
Draw movetool gizmo in OnDrawGizmos() 1 Answer
Move from one object to another 0 Answers
Make a "Blinking/Moving/Animating" GUI 1 Answer
pixelInset to Move a GUITexture C# 0 Answers