In trying to make sure I understood the concept of singletons, I created a way to do it with a string, "on and “off”. Was wondering why you shouldn’t do this? It works, but I’m wondering if it will create problems down the line.
using UnityEngine;
using System.Collections;
public class MusicPlayer : MonoBehaviour {
static string music_switch = "off";
void Awake () {
if (music_switch == "on"){
Destroy(gameObject);
}
else {
music_switch = "on";
DontDestroyOnLoad(gameObject);
}
}
}