x


MouseDown on GUI.button

Hi,

I want to check if I am holding down my mouse when using a GUI.button. I have been searching the forum but I can't find anything that works:

here is how a single mouse click works. Only thing left to do is check for mouseDown instead of mouseClick

if (GUI.Button(new Rect(Screen.width / 2 - 50 , Screen.height - 40, 25, 25), "", "leftArrow"))
    {
        //do something
    }
more ▼

asked Dec 21 '10 at 08:14 PM

Jorn gravatar image

Jorn
52 3 3 7

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Have you tried RepeatButton

:- Make a button that is active as long as the user holds it down.

more ▼

answered Dec 21 '10 at 08:49 PM

diabloroxx gravatar image

diabloroxx
739 5 7 13

thanks for the help!

Dec 22 '10 at 10:26 AM Jorn
(comments are locked)
10|3000 characters needed characters left

What you're looking for is the UI widget 'RepeatButton' which repeatedly returns true while the user holds left mouse button down over it:

http://unity3d.com/support/documentation/ScriptReference/GUI.RepeatButton.html http://unity3d.com/support/documentation/ScriptReference/GUILayout.RepeatButton.html

more ▼

answered Dec 21 '10 at 08:53 PM

heks gravatar image

heks
76 3

Thanks for your help!

Dec 22 '10 at 10:26 AM Jorn
(comments are locked)
10|3000 characters needed characters left
more ▼

answered Dec 21 '10 at 08:32 PM

dissidently gravatar image

dissidently
480 51 55 60

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5104
x1313
x1134
x70

asked: Dec 21 '10 at 08:14 PM

Seen: 9725 times

Last Updated: Dec 21 '10 at 08:14 PM