// Use this for initialization private void Awake() { //Check if there is already an instance of SoundManager if (instance == null) { //if not, set it to this. instance = this; } //If instance already exists: else if (instance != this) { //Destroy this, this enforces our singleton pattern so there can only be one instance of SoundManager. Destroy(gameObject); } }
// Use this for initialization void Start() { // AudioSource jouerMusique; // InvokeRepeating("bool_switch", 1, 1); DontDestroyOnLoad(transform.gameObject); // SoundOn = true; Sound = GameObject.Find("Son_2"); music = GameObject.Find("Musique"); MusiqueScript = GameObject.Find("Musique"); didi = MusiqueScript.GetComponent <dontDestroy_load_sound>(); if (didi.SoundOn) { Sound.SetActive(true); } else { //Sound.SetActive(false); StartCoroutine(LateCall()); } }