예제 #1
0
 void Start()
 {
     for (int i = 0; i < sourceCount; i++)
     {
         AudioSource source = gameObject.AddComponent <AudioSource>();
         source.volume  = SoundManager.AMB_VOLUME;
         source.enabled = false;
         source.loop    = true;
         SoundPlayItem soundItem = new SoundPlayItem(source);
         soundPlayItems.Add(soundItem);
     }
 }
예제 #2
0
    void OnDestroy()
    {
        if (soundItem1 != null)
        {
            soundItem1.Stop();
        }

        if (soundItem2 != null)
        {
            soundItem2.Stop();
        }
        mainSoundItem = null;
        soundItem1    = null;
        soundItem2    = null;
    }
예제 #3
0
    void Start()
    {
        AudioSource source = gameObject.AddComponent <AudioSource>();

        source.volume  = SoundManager.BGM_VOLUME;
        source.enabled = false;
        source.loop    = true;
        soundItem1     = new SoundPlayItem(source);

        source         = gameObject.AddComponent <AudioSource>();
        source.volume  = SoundManager.BGM_VOLUME;
        source.enabled = false;
        source.loop    = true;
        soundItem2     = new SoundPlayItem(source);
    }
예제 #4
0
 public void PlaySound(string soundName, float vol = 1, float inTime = 0)
 {
     if (mainSoundItem != null && mainSoundItem.currentPlaySoundName == soundName)
     {
         return;
     }
     if (mainSoundItem == soundItem1)
     {
         mainSoundItem = soundItem2;
         soundItem1.Stop(inTime);
         soundItem2.PlaySound(SoundType.BGM, soundName, true, SoundManager.BGM_VOLUME * vol, inTime);
     }
     else
     {
         mainSoundItem = soundItem1;
         soundItem2.Stop();
         soundItem1.PlaySound(SoundType.BGM, soundName, true, SoundManager.BGM_VOLUME * vol, inTime);
     }
 }
예제 #5
0
 public void PlaySound(AudioClip clip, float vol = 1, float inTime = 1f)
 {
     if (mainSoundItem != null && mainSoundItem.currentPlaySoundName == clip.name)
     {
         return;
     }
     if (mainSoundItem == soundItem1)
     {
         mainSoundItem = soundItem2;
         soundItem1.Stop(inTime);
         soundItem2.PlaySound(clip, true, SoundManager.BGM_VOLUME * vol, inTime);
     }
     else
     {
         mainSoundItem = soundItem1;
         soundItem1.PlaySound(clip, true, SoundManager.BGM_VOLUME * vol, inTime);
         soundItem2.Stop(inTime);
     }
 }
예제 #6
0
 public void Stop()
 {
     soundItem1.Stop();
     soundItem2.Stop();
     mainSoundItem = null;
 }
예제 #7
0
 //停止背景声音
 public void Stop(float outTime)
 {
     soundItem1.Stop(outTime);
     soundItem2.Stop(outTime);
     mainSoundItem = null;
 }