is there a way to detect that button is hovered? is there a function that checks that?
currently i am detecting if mouse position belongs to the button rect which is slow if you have a list of buttons
is there a way to handle this the other way?
thanks!
When you pass a GUI element a GUIContent with a tooltip, you can easily detect if that button is being hovered by checking if the global GUI.tooltip has content set, and checknig what that content is. For instance:
function OnGUI(){
GUI.Button (Rect (10,10,100,20), GUIContent ("MyButton", "MyButtonTooltip"));
if(GUI.tooltip == "MyButtonTooltip"){
//The button "MyButton" is currently being hovered
}
}