84 lines
1.7 KiB
C#
84 lines
1.7 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SkySettingsSlider : MonoBehaviour
|
|
{
|
|
public enum SettingType
|
|
{
|
|
COLOR_R = 0,
|
|
COLOR_G = 1,
|
|
COLOR_B = 2,
|
|
ALTITUDE = 3
|
|
}
|
|
|
|
public SettingType settingType = SettingType.ALTITUDE;
|
|
|
|
public Text label;
|
|
|
|
public Slider slider;
|
|
|
|
public SkySettings skySettings;
|
|
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
Refresh();
|
|
}
|
|
|
|
public void Refresh()
|
|
{
|
|
if ((bool)skySettings)
|
|
{
|
|
if (settingType == SettingType.ALTITUDE)
|
|
{
|
|
slider.value = skySettings.azureSky_Controller.AltitudeCurve[0].Evaluate(0f);
|
|
}
|
|
else if (settingType == SettingType.COLOR_R)
|
|
{
|
|
slider.value = skySettings.azureSky_Controller.LambdaCurveR[0].Evaluate(0f);
|
|
}
|
|
else if (settingType == SettingType.COLOR_G)
|
|
{
|
|
slider.value = skySettings.azureSky_Controller.LambdaCurveG[0].Evaluate(0f);
|
|
}
|
|
else if (settingType == SettingType.COLOR_B)
|
|
{
|
|
slider.value = skySettings.azureSky_Controller.LambdaCurveB[0].Evaluate(0f);
|
|
}
|
|
UpdateLabel();
|
|
}
|
|
}
|
|
|
|
public void UpdateValue()
|
|
{
|
|
if ((bool)skySettings)
|
|
{
|
|
skySettings.UpdateSky();
|
|
UpdateLabel();
|
|
}
|
|
}
|
|
|
|
public void UpdateLabel()
|
|
{
|
|
if (settingType == SettingType.ALTITUDE)
|
|
{
|
|
label.text = Utilities.GetTranslation("EDITOR/ALTITUDE") + " " + slider.value.ToString("F2");
|
|
}
|
|
else if (settingType == SettingType.COLOR_R)
|
|
{
|
|
label.text = Utilities.GetTranslation("EDITOR/COLOR") + " R " + slider.value.ToString("F0");
|
|
}
|
|
else if (settingType == SettingType.COLOR_G)
|
|
{
|
|
label.text = Utilities.GetTranslation("EDITOR/COLOR") + " G " + slider.value.ToString("F0");
|
|
}
|
|
else if (settingType == SettingType.COLOR_B)
|
|
{
|
|
label.text = Utilities.GetTranslation("EDITOR/COLOR") + " B " + slider.value.ToString("F0");
|
|
}
|
|
}
|
|
}
|