1
This commit is contained in:
63
unity/Assets/Script/UI/UISetting.cs
Normal file
63
unity/Assets/Script/UI/UISetting.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user