コード例 #1
0
 public void PlaySound(EAudioClip clip)
 {
     if (IsSoundOn)
     {
         soundAudioSource.clip = audioClipList[(int)clip];
         //Debug.Log("###" + (int)clip);
         soundAudioSource.Play();
     }
 }
コード例 #2
0
    public void PlayClip(EAudioClip clip, float volume, bool loop = false, bool dontDestroy = false)
    {
        if (clips[(int)clip] == null)
        {
            return;
        }

        AudioSource audioSource = gameObject.AddComponent <AudioSource>();

        audioSource.loop   = loop;
        audioSource.clip   = clips[(int)clip];
        audioSource.volume = volume;
        audioSource.Play();
        if (!dontDestroy)
        {
            float destroyAfter = clips[(int)clip].length;
            StartCoroutine(RemoveClip(audioSource, destroyAfter));
        }
    }
コード例 #3
0
 public void PlaySoundOnSetting(EAudioClip clip)
 {
     soundAudioSource.clip = audioClipList[(int)clip];
     soundAudioSource.Play();
 }