| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 | 
							- using UnityEngine;
 
- using FairyGUI;
 
- using GFGGame.Launcher;
 
- using YooAsset;
 
- using System.Collections;
 
- namespace GFGGame
 
- {
 
-     public class SoundManager : SingletonMonoBase<SoundManager>
 
-     {
 
-         private AudioSource player;
 
-         private AssetOperationHandle handle;
 
-         private Coroutine coroutine;
 
-         private float _lastVolumn = 1;
 
-         private bool _isOn = true;
 
-         public bool isOn
 
-         {
 
-             get
 
-             {
 
-                 return _isOn;
 
-             }
 
-             set
 
-             {
 
-                 if (_isOn != value)
 
-                 {
 
-                     _isOn = value;
 
-                     if (_isOn)
 
-                     {
 
-                         GRoot.inst.soundVolume = _lastVolumn;
 
-                     }
 
-                     else
 
-                     {
 
-                         _lastVolumn = GRoot.inst.soundVolume;
 
-                         GRoot.inst.soundVolume = 0;
 
-                         Stop();
 
-                     }
 
-                     LocalCache.SetBool(LauncherConfig.SOUND_KEY, _isOn);
 
-                 }
 
-             }
 
-         }
 
-         private void Awake()
 
-         {
 
-             player = this.gameObject.AddComponent<AudioSource>();
 
-             isOn = LocalCache.GetBool(LauncherConfig.SOUND_KEY, true);
 
-             //player.volume = LocalCache.GetFloat(LauncherConfig.SOUND_VOLUMN_KEY, 1);
 
-         }
 
-         private void Start()
 
-         {
 
-         }
 
-         private void Update()
 
-         {
 
-         }
 
-         public void PlayOneShotCroutine(string path)
 
-         {
 
-             if (coroutine != null)
 
-             {
 
-                 StopCoroutine(coroutine);
 
-             }
 
-             handle?.Release();
 
-             if (_isOn)
 
-             {
 
-                 coroutine = StartCoroutine(PlayOneShot(path));
 
-             }
 
-         }
 
-         private IEnumerator PlayOneShot(string path)
 
-         {
 
-             //AudioClip clip = GFGAsset.Load<AudioClip>(path);
 
-             handle = YooAssets.LoadAssetAsync<AudioClip>(path);
 
-             yield return handle;
 
-             player.clip = handle.AssetObject as AudioClip;
 
-             player.Play();
 
-         }
 
-         public void Stop()
 
-         {
 
-             player.Stop();
 
-         }
 
-         public void SetVolumn(float volumn)
 
-         {
 
-             GRoot.inst.soundVolume = volumn;
 
-         }
 
-     }
 
- }
 
 
  |