- Home /
executing As long as button still pressed
how i can execute any function As long as this button still pressed :
if ( GUI.Button (Rect (160,445,100,50), "Shoot")) {
shoot();
}
on keyboard button i write this code and every thing is very good , but i want to apply this on GUI Button .
if (Input.GetKey ("space"))
{
shoot();
}
please i want an easy method in java script because i still new beinner in unity :)
Comment
Best Answer
Answer by liortal · May 01, 2014 at 07:44 PM
You should use a RepeatButton.
Basically, the same code as you posted, only with RepeatButton
:
if ( GUI.RepeatButton (Rect (160,445,100,50), "Shoot")) {
shoot();
}
See the documentation for this method here: http://docs.unity3d.com/Documentation/ScriptReference/GUI.RepeatButton.html
Your answer
Follow this Question
Related Questions
Stop shooting when I press a gui button 1 Answer
Unity GUI Button Options 0 Answers
Disable a GUI while left mouse button is Down? 2 Answers
GUI.Label positioning for many device resolutions 1 Answer
Resolutions 1 Answer