SHADE_Y3/Assets/Scripts/UI/SC_Options.cs

80 lines
1.8 KiB
C#
Raw Permalink Normal View History

2023-03-07 10:08:30 +08:00
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.UI
{
2023-03-08 16:22:05 +08:00
public class Options : Script
{
public GameObject masterVolSlider;
public GameObject sfxVolSlider;
public GameObject bgmVolSlider;
public GameObject fovSlider;
protected override void awake()
{
Slider mv = masterVolSlider.GetComponent<Slider>();
Slider sfx = sfxVolSlider.GetComponent<Slider>();
Slider bgm = bgmVolSlider.GetComponent<Slider>();
Slider fov = fovSlider.GetComponent<Slider>();
if (mv != null)
{
mv.ScaledValue = Settings.masterVolume;
}
if (sfx != null)
{
sfx.ScaledValue = Settings.sfxVolume;
}
if (bgm != null)
{
bgm.ScaledValue = Settings.bgmVolume;
}
if (fov != null)
{
fov.ScaledValue = Settings.cameraFOV;
}
}
protected override void update()
2023-03-07 10:08:30 +08:00
{
2023-03-08 16:22:05 +08:00
Slider mv = masterVolSlider.GetComponent<Slider>();
Slider sfx = sfxVolSlider.GetComponent<Slider>();
Slider bgm = bgmVolSlider.GetComponent<Slider>();
Slider fov = fovSlider.GetComponent<Slider>();
if (mv != null)
{
2023-03-10 18:07:40 +08:00
Settings.masterVolume = mv.ScaledValue;
SHADE.Audio.SetVCAVolume("vca:/MASTER", Settings.masterVolume * 0.01f);
2023-03-08 16:22:05 +08:00
}
if (sfx != null)
{
2023-03-10 18:07:40 +08:00
Settings.sfxVolume = sfx.ScaledValue;
SHADE.Audio.SetVCAVolume("vca:/SFX", Settings.sfxVolume * 0.01f);
SHADE.Audio.SetVCAVolume("vca:/UI", Settings.sfxVolume * 0.01f);
2023-03-08 16:22:05 +08:00
}
if (bgm != null)
{
2023-03-10 18:07:40 +08:00
Settings.bgmVolume = bgm.ScaledValue;
SHADE.Audio.SetVCAVolume("vca:/MUSIC", Settings.bgmVolume * 0.01f);
2023-03-08 16:22:05 +08:00
}
if (fov != null)
{
Settings.cameraFOV = fov.ScaledValue;
}
2023-03-07 10:08:30 +08:00
}
2023-03-08 16:22:05 +08:00
}
2023-03-07 10:08:30 +08:00
}