コード例 #1
0
 private void Awake()
 {
     audioSource.clip = music;
     if (bgm == null)
     {
         DontDestroyOnLoad(gameObject);
         bgm = this;
     }
     else if (bgm != this)
     {
         Destroy(gameObject);
     }
 }
コード例 #2
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }