Ejemplo n.º 1
0
	// Use this for initialization
	void Awake () {
		if (instance != null) {
			Destroy (gameObject); //if we come back to main menu then this music player will stay.
		} else
		{
			instance = this;
			GameObject.DontDestroyOnLoad (gameObject); //carry music player to next scene.
		}
	}
Ejemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        //Make sure this object won't be destroyed
        GameObject.DontDestroyOnLoad(gameObject);

        //Destroy itself if there's another BackrgroundMusicController
        if (musicPlayerScript.instance != null)
        {
            GameObject.DestroyImmediate(gameObject);
            return;
        }

        instance = this;
        SceneManager.sceneLoaded += setupPlanetMusic;
    }