UGS
ResourceManager 수정
public T LoadUI<T>(string name) where T : BaseUI
{
if (UIList.TryGetValue(name, out var cacheUi))
{
return cacheUi as T;
}
var ui = Resources.Load<BaseUI>($"UI/{name}") as T;
if(ui == null)
{
Debug.Log("UI not found");
return null;
}
UIList[name] = ui;
return ui;
}
SoundManager - 볼륨 설정
public float GetMasterVolume()
{
audioMixer.GetFloat(Master_Mixer, out float volume);
return Mathf.Pow(10, volume / 20);
}
public void SetMasterVolume(float volume)
{
volume = Mathf.Max(0, 0.00001f);
audioMixer.SetFloat(Master_Mixer, Mathf.Log10(volume) * 20);
PlayerPrefs.SetFloat("MasterVolume", GetMasterVolume());
}
public float GetBGMVolume()
{
audioMixer.GetFloat(Bgm_Mixer, out float volume);
return Mathf.Pow(10, volume / 20);
}
public void SetBGMVolume(float volume)
{
volume = Mathf.Max(0, 0.00001f);
audioMixer.SetFloat(Bgm_Mixer, Mathf.Log10(volume) * 20);
PlayerPrefs.SetFloat("BgmVolume", GetBGMVolume());
}
public float GetSFXVolume()
{
audioMixer.GetFloat(Sfx_Mixer, out float volume);
return Mathf.Pow(10, volume / 20);
}
public void SetSFXVolume(float volume)
{
volume = Mathf.Max(0, 0.00001f);
audioMixer.SetFloat(Sfx_Mixer, Mathf.Log10(volume) * 20);
PlayerPrefs.SetFloat("SfxVolume", GetSFXVolume());
}
public void LoadVolume()
{
SetMasterVolume(PlayerPrefs.GetFloat("MasterVolume", 1f));
SetMasterVolume(PlayerPrefs.GetFloat("BgmVolume", 1f));
SetMasterVolume(PlayerPrefs.GetFloat("SfxVolume", 1f));
}