I’m currently watching this Unity Tutorial on the UI and how to have background music come along in multiple scenes. The problem is that the “DontDestroy” script somehow doesn’t work?
Around (24:30)
This is the code I’m using. Google has some slight variations, but most come back to this simple one.
using UnityEngine;
using System.Collections;
public class DontDestroy : MonoBehaviour {
void awake()
{
DontDestroyOnLoad(gameObject);
}
}
I attach the script to my backgroundmusic object, I press play and then press the button that loads the next scene, but for some reason this object is still destroyed and the music stops… What am I missing here?