using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class SoundManager : MonoBehaviour {
[System.Serializable]
public class SoundGroup{
public AudioClip audioClip;
public string soundName;
}
public AudioSource bgmSound;
public List<SoundGroup> sound_List = new List<SoundGroup>();
public static SoundManager instance;
public void Start(){
instance = this;
StartCoroutine(StartBGM());
}
public void PlayingSound(string _soundName){
AudioSource.PlayClipAtPoint(sound_List[FindSound(_soundName)].audioClip, Camera.mainCamera.transform.position);
}
private int FindSound(string _soundName){
int i = 0;
while( i < sound_List.Count ){
if(sound_List[i].soundName == _soundName){
return i;
}
i++;
}
return i;
}
void ManageBGM()
{
StartCoroutine(StartBGM());
}
//Start BGM when loading complete
IEnumerator StartBGM()
{
yield return new WaitForSeconds(0.5f);
// while(PatternSystem.instance.loadingComplete == false)
// {
// yield return 0;
// }
Debug.Log("play");
  bgmSound.Play();
}
}


声音播放
 SoundManager.instance.PlayingSound("Step");


音乐

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-10-09
  • 2021-10-10
  • 2021-08-13
  • 2022-12-23
猜你喜欢
  • 2021-07-10
  • 2021-05-19
  • 2022-12-23
  • 2021-09-19
  • 2021-04-14
  • 2022-02-17
相关资源
相似解决方案