コード例 #1
0
        AudioSource FindReadyAudioSource(AudioClipInfo audioClipInfo)
        {
            for (int i = 0; i < audioClipInfo.audioSource.Count; i++)
            {
                if (!audioClipInfo.audioSource[i].isPlaying)
                {
                    Debug.Log("Found");
                    return(audioClipInfo.audioSource[i]);
                }
            }

            Debug.Log("No Ready Audio Sources");
            return(null);
        }
コード例 #2
0
        public void PlaySFX(AudioClipID audioClipID)
        {
            AudioClipInfo clipToPlay = FindAudioClip(audioClipID);

            if (clipToPlay == null)
            {
                return;
            }

            AudioSource player = FindReadyAudioSource(clipToPlay);

            if (player != null)
            {
                player.PlayOneShot(clipToPlay.audioClip, sfxVolume);
            }
        }
コード例 #3
0
        public void PlayBGMWithFadeOutIn(AudioClipID audioClipID, float fadeOutDuration, float fadeInDuration)
        {
            AudioClipInfo clipToPlay = FindAudioClip(audioClipID);

            if (clipToPlay == null)
            {
                return;
            }

            AudioSource player = FindReadyAudioSource(clipToPlay);

            if (player != null)
            {
                player.loop = true;
                StartCoroutine(FadeOutIn(player, fadeOutDuration, fadeInDuration, bgmVolume));
            }
        }
コード例 #4
0
        public void PlayBGM(AudioClipID audioClipID)
        {
            AudioClipInfo clipToPlay = FindAudioClip(audioClipID);

            if (clipToPlay == null)
            {
                return;
            }

            AudioSource player = FindReadyAudioSource(clipToPlay);

            if (player != null)
            {
                player.volume = bgmVolume;
                player.loop   = true;
                player.Play();
            }
        }