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 :slight_smile:

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: Unity - Scripting API: GUI.RepeatButton