コード例 #1
0
 void Awake()
 {
     if (instance != null && instance != this) {
         Destroy(this.gameObject);
         return;
     }
     else {
         instance = this;
         DontDestroyOnLoad(gameObject);
         soundSource = gameObject.AddComponent<AudioSource>();
         soundSource.loop = true;
         soundSource.volume = volume;
         soundSource.clip = sound;
         soundSource.Play();
     }
 }
コード例 #2
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
         soundSource        = gameObject.AddComponent <AudioSource>();
         soundSource.loop   = true;
         soundSource.volume = volume;
         soundSource.clip   = sound;
         soundSource.Play();
     }
 }