Is there a way to limit how many times a GUI button can be pressed?
Something like this (untested):
private var counter = 0;
function OnGUI() {
GUI.enabled = counter <= 4;
if (GUILayout.Button("Button")) {
counter++;
}
GUI.enabled = true;
}
Make sense?
Cheers,
-Jon
Thanks, that did the trick in disabling the button. I would I loop this so it continues to run?
var On = true;
function OnGUI() {
GUI.enabled = On == true;
if (GUI.Button (Rect (70, 400, 200, 50), "Shoot"))
{ rigidbody.velocity.y = 5;
rigidbody.velocity.z = 5;
On = false;
}
}
yield WaitForSeconds(2);
On = true;
EDIT-
nevermind, I figured it out. Thanks for the help. Without the forums newbs like me would be screwed