- Home /
Audio not playing [Fixed]
#pragma strict
var isQuitButton = false;
var isInfoButton = false;
var sound1 : AudioClip;
function OnMouseEnter () {
renderer.material.color = Color.red;
}
function OnMouseExit () {
renderer.material.color = Color.white;
}
function OnMouseUp(){
if(isQuitButton){
Application.Quit();
audio.PlayOneShot(sound1);
}
else if(isInfoButton){
Application.LoadLevel(2);
audio.PlayOneShot(sound1);
}
else{
Application.LoadLevel(1);
audio.PlayOneShot(sound1);
}
}
When i click on the text it says; "MissingComponentException: There is no 'AudioSource' attached to the "Play_text" game object, but a script is trying to access it. You probably need to add a AudioSource to the game object "Play_text". Or your script needs to check if the component is attached before using it." even though i have a .WAV file attached to it.
Answer by IndieScapeGames · Jan 06, 2014 at 06:12 PM
Click on the object in the Scene tab, then in the Inspection tab, select 'Add Component', and start typing 'Audio Source' without the quotes. It should appear in the list, and go ahead and add the source that way.
Then all it does is play the Click sound when i start the game. I want it to play when i click the text.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Sound playing at random. (JS) 2 Answers
Play sound when out of ammo 0 Answers
GuiTexture Width Change 1 Answer
Add force to GameObject 2 Answers