| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 | 
							- using System;
 
- using UnityEngine;
 
- using GFGGame.Launcher;
 
- namespace GFGGame
 
- {
 
-     public class MusicManager : SingletonMonoBase<MusicManager>
 
-     {
 
-         private AudioSource _player;
 
-         private string _currentName;
 
-         private bool _isOn = true;
 
-         public bool isOn
 
-         {
 
-             get
 
-             {
 
-                 return _isOn;
 
-             }
 
-             set
 
-             {
 
-                 if(_isOn != value)
 
-                 {
 
-                     _isOn = value;
 
-                     if(_isOn)
 
-                     {
 
-                         if(_currentName != null)
 
-                         {
 
-                             Play(_currentName, true);
 
-                         }
 
-                     }
 
-                     else
 
-                     {
 
-                         Stop();
 
-                     }
 
-                     LocalCache.SetBool(LauncherConfig.MUSIC_KEY, _isOn);
 
-                 }
 
-             }
 
-         }
 
-         private void Awake()
 
-         {
 
-             _player = this.gameObject.AddComponent<AudioSource>();
 
-             _player.loop = true;
 
-         }
 
-         private void Start() 
 
-         {
 
-             
 
-         }
 
-         private void Update() 
 
-         {
 
-             
 
-         }
 
-         public void Play(string path, bool must = false)
 
-         {
 
-             if(_currentName != path || must)
 
-             {
 
-                 _currentName = path;
 
-                 if(_isOn)
 
-                 {
 
-                     AudioClip clip = GFGAsset.Load<AudioClip>(path);
 
-                     _player.clip = clip;
 
-                     _player.Play();
 
-                 }
 
-             }
 
-         }
 
-         public void PlayByUrl(string url, bool must = false)
 
-         {
 
-             if (_currentName != name || must)
 
-             {
 
-                 _currentName = name;
 
-                 //如果是播人声是不受音乐开关影响
 
-                 //if (_isOn)
 
-                 //{
 
-                     AudioClip clip = GFGAsset.Load<AudioClip>(url);
 
-                     _player.clip = clip;
 
-                     _player.PlayOneShot(clip);
 
-                 //}
 
-             }
 
-         }
 
-         public float GetSoundTime()
 
-         {
 
-             if (_player.clip != null)
 
-             {
 
-                 return _player.clip.length;
 
-             }
 
-             return 0;
 
-         }
 
-         public void Pause()
 
-         {
 
-             _player.Pause();
 
-         } 
 
-         public void UnPause()
 
-         {
 
-             _player.UnPause();
 
-         }
 
-         public void Stop()
 
-         {
 
-             _player.Stop();
 
-         }
 
-     }
 
- }
 
 
  |