So I have been trying for ages now on what should be a perfectly simple script. All I need to it do is add 1 to a number on the GUI when i press a button. Except it just won't work. And yes I've searched but everything I have found has been for something different or for a much more complicated function.
So far I have
public var ShotsFired : String = "0";
function OnGUI() {
GUI.Label(Rect(100, 100, 140, 20), ShotsFired);
}
function Update () {
if (Input.GetButtonDown("Fire1")) {
print ("you clicked the icon");
ShotsFired += 1;
}
}
I assume the button press is being captured correctly. If that's the case, try changing ShotsFired to an integer instead of a String.
public var ShotsFired : int = 0;
function OnGUI() {
GUI.Label(Rect(100, 100, 140, 20), ShotsFired.ToString());
}
function Update () {
if (Input.GetButtonDown("Fire1")) {
print ("you clicked the icon");
ShotsFired += 1;
}
}
What currently happens? Does it print out 1, then 11, then 111, etc.?