Since moving code into void awake music is no longer persistent between scenes, I can’t work out what I’ve done different from Ben’s code.
using UnityEngine;
using System.Collections;
public class MusicPlayer : MonoBehaviour {
static MusicPlayer instance = null;
void awake () {
if (instance != null) {
Destroy (gameObject);
print ("Duplicate Music Player destroyed");
} else {
instance = this;
GameObject.DontDestroyOnLoad(gameObject);
}
}
// Update is called once per frame
void Update () {
}
}
Also when I added the debug logs the “music player awake” message would never appear in the console.