- Home /
Settings Screen Help
I have no clue how to word this, but i'm going to try my best...
In some games, they have a feature where, when you enter the menu from in-game, say a "pause menu", they have options to settings, quit, skills, ect. And whenever they activate one of these options, they go to another menu. Now, my question is how they keep the music the same throughout the entire menu.
I'll try to word this better...
I want to keep the music the same throughout the entire pause menu, how do i do this? Thanks!
Answer by kalen_08 · Jul 19, 2018 at 09:01 PM
If you have your music player on it's own gameObject which you should, then have it like this:
public class MusicPlayer : MonoBehaviour {
void Awake ()
{
if (FindObjectsOfType<MusicPlayer>().length > 1) {
Destroy (gameObject);
} else {
DontDestroyOnLoad (gameObject);
}
}
}
This will mean it doesn't get destroyed but if there's another one then it will destroy itself so there's only one.
Option #2 is that you don't change scenes when going to the menu. Unless your game is a simple one in which case it's best then to use the above solution
Let me know if you need anything else :)
On option #2 are you saying that when in a game menu you can make it to where you can activate different tabs of the menu without changing the scene?
Your answer
