Skip to content

Instantly share code, notes, and snippets.

@sampattuzzi
Created August 3, 2016 13:58
Show Gist options
  • Save sampattuzzi/7985fc391bc016de730c46baf6d2a28e to your computer and use it in GitHub Desktop.
Save sampattuzzi/7985fc391bc016de730c46baf6d2a28e to your computer and use it in GitHub Desktop.
public class MusicPlayer : MonoBehaviour {
static MusicPlayer instance = null;
void Start () {
if (instance != null) {
Destroy (gameObject);
print ("Duplicate music player self-destructing!");
} else {
instance = this;
GameObject.DontDestroyOnLoad(gameObject);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment