using UnityEngine; using FairyGUI; using GFGGame.Launcher; namespace GFGGame { public class SoundManager : SingletonMonoBase { private AudioSource _player; private bool _isOn = true; public bool isOn { get { return _isOn; } set { if(_isOn != value) { _isOn = value; if(_isOn) { GRoot.inst.soundVolume = 1; } else { GRoot.inst.soundVolume = 0; Stop(); } LocalCache.SetBool(LauncherConfig.SOUND_KEY, _isOn); } } } private void Awake() { _player = this.gameObject.AddComponent(); } private void Start() { } private void Update() { } public void PlayOneShot(string Path) { if(_isOn) { AudioClip clip = GFGAsset.Load(Path); _player.clip = clip; _player.PlayOneShot(clip); } } public void PlayClipAtPoint(string path, Vector3 position) { if (_isOn) { AudioClip clip = GFGAsset.Load(path); AudioSource.PlayClipAtPoint(clip, position); } } public void Stop() { _player.Stop(); } } }