UI框架开发中

This commit is contained in:
2025-09-29 07:45:07 +08:00
parent 423ad80303
commit 71edbb6088
39 changed files with 1191 additions and 397 deletions

View File

@@ -0,0 +1,37 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Audio;
public class AudioPanel : UIBasePanel, ISettingsPanel
{
[SerializeField] private Slider masterVolumeSlider;
[SerializeField] private AudioMixer audioMixer;
private void OnEnable()
{
masterVolumeSlider.value = SettingsManager.Inst.CurrentSettings.masterVolume;
if (audioMixer == null) audioMixer = FindAnyObjectByType<AudioMixer>();
}
public void OnMasterVolumeChanged(float value)
{
SettingsManager.Inst.CurrentSettings.masterVolume = value;
SetVolume(value);
}
public void ApplySettings()
{
SetVolume(SettingsManager.Inst.CurrentSettings.masterVolume);
}
private void SetVolume(float volume)
{
if (audioMixer)
audioMixer.SetFloat("MasterVolume", Mathf.Log10(Mathf.Max(volume, 0.0001f)) * 20);
}
public void ResetToDefault()
{
throw new System.NotImplementedException();
}
}