- Home /
Stop music playing after changing scenes.
I have a main menu that plays music and i click on a button that takes to me to a different scene, the music continues to play (Good) but when i go to the main game it continues to play (This is what i want to stop). I have tried many things and the one that i think should work doesn't.
if (Application.loadedLevel == 0)
{
DontDestroyOnLoad(transform.gameObject);
}
else
if (Application.loadedLevel == 2)
{
Destroy (gameObject);
}
The script has the code to play the music and that's why i have to don't destroy on load, i thought that if i deleted the object the music would stop. I get no errors in the console it just doesn't work.
Please try and help me.
Thank you for answers
Answer by FirePlantGames · Nov 26, 2014 at 11:14 PM
You need to get rid of the else, if that doesn't work make sure that you have the third scene in your build settings loaded.
And your sure that you're you have the third scene loaded? (It will be marked 2 in the build settings)
Your answer
Follow this Question
Related Questions
How to stop audio 1 Answer
Mute audio in every scene problem 1 Answer
Audio keeps playing when paused 1 Answer
Stop AudioClips by script (c#) 1 Answer
Problem with many audio sources playing at the same time 1 Answer