Quantcast
Channel: Latest Questions by khoatic
Viewing all articles
Browse latest Browse all 97

Checking for idle hover using tooltips

$
0
0
So I recently started using tooltips to detect when the mouse hovers over a GUI.Button to play a sound. I have it so it works when you hover over the button it fires the sound, but if the mouse stays hovering the button it keeps refiring the sound. I know it has something to do with the tooltips setup I just cant figure out what. Please help. private bool canHoverSound = true; void OnGUI() { diffW = (Screen.width / (setWidth / 100)) / 100; diffH = (Screen.height / (setHeight / 100)) / 100; if (GUI.Button(new Rect(posX * diffW, posY * diffH, sizeX * diffW, sizeY * diffH), new GUIContent("","Mouse Over Button"), defaultStyle)) { //BUT CLICK STUFF } if (GUI.tooltip == "Mouse Over Button") { if (canHoverSound) { FMOD.Studio.PLAYBACK_STATE state; FMOD_StudioSystem.ERRCHECK(hoverSound.getPlaybackState(out state)); if (state == FMOD.Studio.PLAYBACK_STATE.STOPPED) { hoverSound.start(); } canHoverSound = false; } } else { canHoverSound = true; } }

Viewing all articles
Browse latest Browse all 97

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>