void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
void Awake() { if (instance != null && instance != this) { if (instance.GetComponent <AudioSource>().clip != GetComponent <AudioSource>().clip) { instance.GetComponent <AudioSource>().clip = GetComponent <AudioSource>().clip; instance.GetComponent <AudioSource>().volume = GetComponent <AudioSource>().volume; instance.GetComponent <AudioSource>().Play(); } Destroy(this.gameObject); return; } instance = this; GetComponent <AudioSource>().Play(); DontDestroyOnLoad(this.gameObject); }