12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using UnityEngine;
- using FairyGUI;
- using GFGGame.Launcher;
- namespace GFGGame
- {
- public class SoundManager : SingletonMonoBase<SoundManager>
- {
- 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<AudioSource>();
- }
- private void Start()
- {
-
- }
- private void Update()
- {
-
- }
- public void PlayOneShot(string Path)
- {
- if(_isOn)
- {
- AudioClip clip = GFGAsset.Load<AudioClip>(Path);
- _player.clip = clip;
- _player.PlayOneShot(clip);
- }
- }
- public void PlayClipAtPoint(string path, Vector3 position)
- {
- if (_isOn)
- {
- AudioClip clip = GFGAsset.Load<AudioClip>(path);
- AudioSource.PlayClipAtPoint(clip, position);
- }
- }
- public void Stop()
- {
- _player.Stop();
- }
- }
- }
|