- Home /
Counter of clicks after gui.button pressed
Hi, Im trying a RTS game. I use gui.button to select type of soldiers and spawn it in map, each click on map spawns one soldier.
I need to counter that clicks to control how many soldiers have been spawned.
I can't find nothing, someone can help me?
Thanks in advance ;)
Answer by 07Mr07 · Feb 06, 2014 at 06:14 PM
Maybe you don't understand me :)
I did with :
if(Input.GetMouseButtonDown(0))
{
cont++;
}
Answer by TheRefoH · Feb 05, 2014 at 07:08 PM
http://docs.unity3d.com/Documentation/ScriptReference/GUI.Button.html
var i : int = 0;
function OnGUI()
{
if (GUI.Button(Rect(10,10,50,50),btnTexture))
{
i += 1;
}
}
This should count each click on the button and store the number in "i".
Your answer
Follow this Question
Related Questions
How do I create a Gmod item spawn menu in unity? 0 Answers
Spawn Object On Gui (button Press) 2 Answers
How to hook up the particle system to jump animation? 1 Answer
Make more buttons appear, on button click. 1 Answer
GUI Button Animation Cue 1 Answer