I am working on a main menu where if you hover over a button it will play a sound, for example if I hover over the start button, a sound will play: “start the game” but the problem is when I hover over the sound it gets stretched.
This is my code
//Script Main Menu
//Inspector Var's
var hover : String;
var StartGame : AudioClip;
var Credits : AudioClip;
var Exit: AudioClip;
var HomePage: AudioClip;
var Tutorial: AudioClip;
//Private Var's
function OnGUI ()
{
//make a group on the centre of the screen
GUI.BeginGroup (Rect(Screen.width / 2-50, Screen.height /2-50,100,205));
//make a box to see the group on screen
GUI.Box (Rect(0,0,100,205),"Main Menu");
//add buttons for game navigation
if (GUI.Button (Rect(10,30,80,30), GUIContent ("Start Game", "Button 1")))
{
Application.LoadLevel("screenLoad");
}
hover = GUI.tooltip;
if(hover=="Button 1")
audio.PlayOneShot(StartGame);
//add buttons for game navigation
if (GUI.Button (Rect(10,65,80,30), GUIContent ("Credits", "Button 2")))
{
Application.LoadLevel("screenCredit");
}
hover = GUI.tooltip;
if(hover=="Button 2")
audio.PlayOneShot(Credits);
//add buttons for game navigation
if (GUI.Button (Rect(10,100,80,30), GUIContent ("Exit", "Button 3")))
{
Application.Quit();
}
hover = GUI.tooltip;
if(hover=="Button 3")
audio.PlayOneShot(Exit);
//add buttons for game navigation
if (GUI.Button (Rect(10,135,80,30), GUIContent ("Homepage", "Button 4")))
{
Application.OpenURL("http://meria-doc.tumblr.com");
}
hover = GUI.tooltip;
if(hover=="Button 4")
audio.PlayOneShot(HomePage);
if (GUI.Button (Rect(10,169,80,30), GUIContent ("Tutorial", "Button 5")))
{
Application.LoadLevel("TutorialLoad");
}
hover = GUI.tooltip;
if(hover=="Button 5")
audio.PlayOneShot(Tutorial);
GUI.EndGroup();
}