Beispiel #1
0
        private void Awake()
        {
            if (Instance != null)
            {
                Destroy(this.gameObject);
            }
            else
            {
                Instance = this;
            }

            thisTransform = this.transform;
            DontDestroyOnLoad(this.gameObject);

            if (audioListenerObject == null)
            {
                Debug.LogError("not found audiolisterObject");
            }

            //リソース読み込み(同期読み)//
            seAudioClips     = TSMUtil.LoadAudioClipsFromResourcesFolder(seAudioClipPath);
            bgmAudioClips    = TSMUtil.LoadAudioClipsFromResourcesFolder(bgmAudioClipPath);
            jingleAudioClips = TSMUtil.LoadAudioClipsFromResourcesFolder(jingledAudioClipPath);

            //オーディオソースの生成//
            bgmAudioSourceList = TSMUtil.InstantiateAudioSourceList(2, true, this.gameObject, mixerBGM);
            seAudioSourceList  = TSMUtil.InstantiateAudioSourceList(seMaxNum, false, this.gameObject, mixerSE);
            jingleAudioSource  = TSMUtil.InstantiateAudioSource(false, this.gameObject, mixerJINGLE);
        }
Beispiel #2
0
        public void PlayBGMWithFade(string clipName, float fadeTime = DEFAULT_FADETIME, Action callback = null)
        {
            AudioClip clip = TSMUtil.GetAudioClipFromLoadedList(clipName, bgmAudioClips);

            if (bgmAudioSourceList.Find(source => source.clip == clip))
            {
                return;
            }

            AudioSource audioSouce = bgmAudioSourceList.FirstOrDefault(source => !source.isPlaying);

            if (audioSouce != null)

            {
                if (fadeTime == 0f)
                {
                    fadeTime = DEFAULT_FADETIME;
                }

                StopBGMWithFade(fadeTime);
                audioSouce.clip = clip;

                callback += () => { currentFadeInCoroutine = null; };
                currentFadeInCoroutine = StartCoroutine(audioSouce.FadeIn(fadeTime, callback));
            }
        }
Beispiel #3
0
        public void PlayJingle(string jingleName)
        {
            if (jingleAudioSource.isPlaying)
            {
                jingleAudioSource.Stop();
            }

            jingleAudioSource.clip = TSMUtil.GetAudioClipFromLoadedList(jingleName, jingleAudioClips);
            jingleAudioSource.Play();
        }
Beispiel #4
0
        public void PlaySE(string clipName, float volume)
        {
            //空いているaudioSourceはあるか?//
            AudioSource _audioSource = TSMUtil.GetStoppedAudioSoureFromList(seAudioSourceList);

            if (_audioSource == null)
            {
                Debug.LogWarning("No Audio Source"); return;
            }

            //clipNameのaudioClipはロードされているか?//
            _audioSource.clip = TSMUtil.GetAudioClipFromLoadedList(clipName, seAudioClips);

            _audioSource.volume = volume;
            _audioSource.Play();
            LastPlayedSEName = clipName;
        }
Beispiel #5
0
 public AudioClip GetSEAudioClipFromLoadedList(string clipName)
 {
     return(TSMUtil.GetAudioClipFromLoadedList(clipName, seAudioClips));
 }