Detect when mouseover a gui button?

Is it possible to detect when a gui button is being moused over? The if(GUI.Button)… seems to only detect when it’s pressed not when mouseover

You can generate mouseover and mouseout events.
I’m using the mouseover to play a sound.

You’ll need to add the GUI.Content tooltip to the buttons you’re wanting to do this with giving them unique tips so we can identify which ones we’re interacting with.

This is mostly taken from: Unity\Editor\Data\Documentation\Documentation\ScriptReference\GUI-tooltip.html


var lastTooltip : String = " ";

function OnGUI () {

if(GUI.Button(Rect( buttonX, buttonY - buttonHeight, buttonWidth, buttonHeight),GUIContent ("Start Game", "Button1")) == true) {		

if (Event.current.type == EventType.Repaint && GUI.tooltip != lastTooltip) {        
	if (lastTooltip != "") {
		 SendMessage (lastTooltip + "OnMouseOut", SendMessageOptions.DontRequireReceiver);      
	if (GUI.tooltip != "") {
		SendMessage (GUI.tooltip + "OnMouseOver", SendMessageOptions.DontRequireReceiver);
	lastTooltip = GUI.tooltip; 


function Button1OnMouseOver () {
//Debug.Log (“Play game got focus”);


function Button1OnMouseOut () {

Debug.Log (“Button Lost Focus”);