using System.Net.NetworkInformation; using UnityEngine; /* Home场景全局控制音效播放 */ public class HomeSoundEffectController: MonoBehaviour { public static HomeSoundEffectController Instance; //音效相关 public AudioSource audioSource; public AudioClip[] soundEffect; void Awake() { // 单例模式,确保只有一个GlobalSoundManager if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } } public void PlaySoundEffect(int id) { audioSource.PlayOneShot(soundEffect[id]); } }