Music Player no longer working properly after section 69 changes

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.

1 Like

Awake needs a capital A

1 Like

I love it when a solution is as simple as I am!

Lol, it happens to all of us :wink:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms