SCRIPTING EVENTS for GUIButtons- HELP

Hello,

Im looking for some help on handling events on GUI.Button or GUI.Repeat Button, but unfortunately i didnt find any source that states the use of any event handler in OnGUI()

What i am trying is to call a function1 when a button is pressed , function2 when it is hovered function3 if it is released

To call function1 when button is pressed , im using :-

function OnGUI()
{
if ( GUI.RepeatButton(Rect(10,10,50,50),“PressMe”) )
{
function1();
}
else
{
function3();
// I want the function 3 to be called when button is released but it is being called every frame even if i have not pressed the button for a single time, and i know it will so bcz ongui will be check the else block evey frame

}
}

if anybody has done similar work, then plz help me with some code or logic

Thanks
…LiVeN…

You want to use GUI.tooltip, which is a global gui var that gets created whenever you hover over a gui button and you pass that gui button’s GUIContent a tooltip. You can kind of hack it to create “OnMouseOver” and “OnMouseOut” events.

The last example on this page will give you a good start.

you can try using the following functions

if(touch.phase == TouchPhase.Began)
if(touch.phase == TouchPhase.Ended)
touch.phase == TouchPhase.Canceled)