private void Awake() { audioSource.clip = music; if (bgm == null) { DontDestroyOnLoad(gameObject); bgm = this; } else if (bgm != this) { Destroy(gameObject); } }
private void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }