Continously sound when gui is held?

Hi, sorry if this is a noob question… :slight_smile: I’m trying to make a boat game and I’m trying to figure out how to make the “fog horn” work. What I wan’t is that the sound is being looped when you hold the gui button down (It’s an Android game). And when you release the gui it should stop the sound. This is my current code:

	if(GUI.Button(new Rect(Screen.width - (TurretBtnAverage * 2),0,TurretBtnAverage,TurretBtnAverage),"", HornBtnGUIStyle)) {
		
		hornSound.audio.Play(); // hornSound is the gameObject where the audioClip is attachted to :-)
		
	}

Thanks, Andreas :slight_smile:

RepeatButton returns true as long as the mouse button is held down on it.

if (GUI.RepeatButton(new Rect(Screen.width - (TurretBtnAverage * 2), 0, TurretBtnAverage, TurretBtnAverage),"", HornBtnGUIStyle))
{
    if (!hornSound.audio.isPlaying)
        hornSound.audio.Play();
}
else
{
    if (hornSound.audio.isPlaying)
        hornSound.audio.Stop();
}