How do I destroy an audio when a specific scene is loaded
So, i have a script that has the function to don't destroy the audio when any scene is loaded:
'private static Music instance;
public static Music GetInstance (){
return instance;
}
void Awake (){
if (instance != null && instance != this) {
Destroy(this.gameObject);
return;
} else {
instance = this;
}
DontDestroyOnLoad(this.gameObject);
}
}`
But, i have a simple problem: I need to destroy this audio if the menu scene is loaded. For example: a music "x" for the menu and another"y" for the game, when you are in the game scene, music "y" keep playing but if you change to menu scene music "x" starts to playing...
Obs: Preferably in C#
I hope you can help me!
Comment
Your answer
Follow this Question
Related Questions
Making a list of images within a scrollrect generated from prefabs tappable/clickable 1 Answer
Android detection not detected by android phone 0 Answers
How to make a system in unity 0 Answers
PlayerPrefs not debugging 1 Answer
My method is being repeated several times during a single input. 1 Answer