如何分离音乐背景和声音效果的开和关(我的意思是如何使分离静音)
AudioManager
public Sound[] sounds;
public static AudioManager instance;
void Awake()
{
if (instance == null)
instance = this;
else
{
Destroy(gameObject);
return;
}
DontDestroyOnLoad(gameObject);
foreach (Sound s in sounds)
{
s.source = gameObject.AddComponent<AudioSource>();
s.source.clip = s.clip;
s.source.volume = s.volume;
s.source.loop = s.loop;
s.source.mute = s.mute;
}
}
Sound.cs
public string name;
public AudioClip clip;
[Range(0f, 1f)]
public float volume;
public bool loop;
public bool mute;
[HideInInspector]
public AudioSource source;