Hi.
i have this small code to aply an object 3D
function Update () {
transform.Rotate(0, 0.4, 0);
}
now my question is, how can I make a GUI.Button
to make stop, and another to begin to start again please ?
thanks a lot.
Hi.
i have this small code to aply an object 3D
function Update () {
transform.Rotate(0, 0.4, 0);
}
now my question is, how can I make a GUI.Button
to make stop, and another to begin to start again please ?
thanks a lot.
I’m away from my development machine, but I think this will work:
private var startRotating = false;
function Update(){
if (startRotating)
transform.Rotate(0, 0.4, 0);
}
function OnGUI(){
if(GUI.Button(Rect(10,10,200,60), "Toggle Rotation"))
startRotating = !startRotating;
}
FYI, you generally want to avoid using OnGUI on the iPhone unless there’s nothing else in the scene but GUI stuff(like at a main menu scene). It’ll kill your performance.