Files
gold_dolphin/unity/Assets/Script/UI/UISetting.cs
2026-06-20 19:35:25 +08:00

64 lines
1.4 KiB
C#

using Manager;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UISetting :UIWindow
{
public Image musicOff;
public Image soundOff;
public Toggle toggleMusic;
public Toggle toggleSound;
public Slider sliderMusic;
public Slider sliderSound;
void Start()
{
this.toggleMusic.isOn = SystemConfig.MusicOn;
this.toggleSound.isOn = SystemConfig.SoundOn;
this.sliderMusic.value = SystemConfig.MusicVolume;
this.sliderSound.value = SystemConfig.SoundVolume;
}
public override void OnYesClick()
{
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
PlayerPrefs.Save();
base.OnYesClick();
}
public void MusicVolume(float vol)
{
SystemConfig.MusicVolume = (int)vol;
PlaySound();
}
public void SoundVolume(float vol)
{
SystemConfig.SoundVolume = (int)vol;
PlaySound();
}
public void MusicToogle(bool on)
{
musicOff.enabled = !on;
SystemConfig.MusicOn = on;
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
}
public void SoundToogle(bool on)
{
soundOff.enabled = !on;
SystemConfig.SoundOn = on;
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
}
float lastPlay = 0;
private void PlaySound()
{
if (Time.realtimeSinceStartup - lastPlay > 0.1)
{
lastPlay = Time.realtimeSinceStartup;
//SoundManager.Instance.PlaySound(SoundDefine.ButtonClick);
}
}
}