311 lines
6.5 KiB
C#
311 lines
6.5 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Artngame.SKYMASTER
|
|
{
|
|
public class UIController : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Transform light1;
|
|
|
|
[SerializeField]
|
|
private GameObject quitButton;
|
|
|
|
[SerializeField]
|
|
private GameObject settingPanel;
|
|
|
|
[SerializeField]
|
|
private GameObject controlsPanel;
|
|
|
|
[SerializeField]
|
|
private GameObject weatherTexture;
|
|
|
|
[SerializeField]
|
|
private List<Button> buttons;
|
|
|
|
[SerializeField]
|
|
private List<GameObject> settingPanels;
|
|
|
|
[SerializeField]
|
|
private Text fpsText;
|
|
|
|
[SerializeField]
|
|
private CloudScript clouds;
|
|
|
|
[SerializeField]
|
|
private WeatherScript weather;
|
|
|
|
private ColorBlock selectedButtonColors;
|
|
|
|
private float deltaTime;
|
|
|
|
private int previousSelection = -1;
|
|
|
|
public void GenerateNewWeatherAction()
|
|
{
|
|
weather.GenerateAndChangeWeatherTexture();
|
|
}
|
|
|
|
public void QuitApp()
|
|
{
|
|
Application.Quit();
|
|
}
|
|
|
|
public void SelectPanel(int panelId)
|
|
{
|
|
settingPanel.SetActive(value: true);
|
|
settingPanels.ForEach(delegate(GameObject p)
|
|
{
|
|
p.SetActive(value: false);
|
|
});
|
|
buttons.ForEach(delegate(Button b)
|
|
{
|
|
b.colors = ColorBlock.defaultColorBlock;
|
|
});
|
|
if (previousSelection != panelId)
|
|
{
|
|
settingPanels[panelId].SetActive(value: true);
|
|
ColorBlock colors = buttons[panelId].colors;
|
|
colors.normalColor = Color.gray;
|
|
colors.highlightedColor = Color.gray;
|
|
buttons[panelId].colors = colors;
|
|
previousSelection = panelId;
|
|
}
|
|
else
|
|
{
|
|
previousSelection = -1;
|
|
settingPanel.SetActive(value: false);
|
|
}
|
|
}
|
|
|
|
public void HideShowWeatherTexture(Text text)
|
|
{
|
|
weatherTexture.SetActive(!weatherTexture.activeSelf);
|
|
text.text = (weatherTexture.activeSelf ? "Hide" : "Show");
|
|
}
|
|
|
|
public void HideShowControls(Text text)
|
|
{
|
|
controlsPanel.SetActive(!controlsPanel.activeSelf);
|
|
text.text = (controlsPanel.activeSelf ? "Hide controls" : "Show controls");
|
|
}
|
|
|
|
public void ToggleLowFreq()
|
|
{
|
|
clouds.debugNoLowFreqNoise = !clouds.debugNoLowFreqNoise;
|
|
}
|
|
|
|
public void ToggleHighFreq()
|
|
{
|
|
clouds.debugNoHighFreqNoise = !clouds.debugNoHighFreqNoise;
|
|
}
|
|
|
|
public void ToggleCurl()
|
|
{
|
|
clouds.debugNoCurlNoise = !clouds.debugNoCurlNoise;
|
|
}
|
|
|
|
public void OnChangeStepCount(Slider slider)
|
|
{
|
|
clouds.steps = (int)slider.value;
|
|
}
|
|
|
|
public void OnChangeLightX(Slider slider)
|
|
{
|
|
light1.localRotation = Quaternion.Euler(slider.value, light1.transform.eulerAngles.y, 0f);
|
|
}
|
|
|
|
public void OnChangeLightY(Slider slider)
|
|
{
|
|
light1.localRotation = Quaternion.Euler(light1.transform.eulerAngles.x, slider.value, 0f);
|
|
}
|
|
|
|
public void OnChangeDownsample(Slider slider)
|
|
{
|
|
clouds.downSample = (int)slider.value;
|
|
}
|
|
|
|
public void ToggleInCLouds()
|
|
{
|
|
clouds.allowFlyingInClouds = !clouds.allowFlyingInClouds;
|
|
}
|
|
|
|
public void ToggleTemporal()
|
|
{
|
|
clouds.temporalAntiAliasing = !clouds.temporalAntiAliasing;
|
|
TemporalReprojection component = GameObject.Find("Main Camera").GetComponent<TemporalReprojection>();
|
|
FrustumJitter component2 = GameObject.Find("Main Camera").GetComponent<FrustumJitter>();
|
|
component.enabled = !component.enabled;
|
|
component2.enabled = !component2.enabled;
|
|
}
|
|
|
|
public void TogglePreCalculatedWeatherTexture()
|
|
{
|
|
weather.useCustomTexture = !weather.useCustomTexture;
|
|
}
|
|
|
|
public void RandomOffsetDropdown(Dropdown dropdown)
|
|
{
|
|
switch (dropdown.value)
|
|
{
|
|
case 0:
|
|
clouds.randomJitterNoise = CloudScript.RandomJitter.Off;
|
|
break;
|
|
case 1:
|
|
clouds.randomJitterNoise = CloudScript.RandomJitter.Random;
|
|
break;
|
|
case 2:
|
|
clouds.randomJitterNoise = CloudScript.RandomJitter.BlueNoise;
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void OnChangeShapeScale(Slider slider)
|
|
{
|
|
clouds.scale = slider.value;
|
|
}
|
|
|
|
public void OnChangeDetailScale(Slider slider)
|
|
{
|
|
clouds.detailScale = slider.value;
|
|
}
|
|
|
|
public void OnChangeCurlScale(Slider slider)
|
|
{
|
|
clouds.curlDistortScale = slider.value;
|
|
}
|
|
|
|
public void OnChangeWeatherScale(Slider slider)
|
|
{
|
|
clouds.weatherScale = slider.value;
|
|
}
|
|
|
|
public void OnChangeShapeMin(Slider slider)
|
|
{
|
|
clouds.lowFreqMin = slider.value;
|
|
}
|
|
|
|
public void OnChangeShapeMax(Slider slider)
|
|
{
|
|
clouds.lowFreqMax = slider.value;
|
|
}
|
|
|
|
public void OnChangeDetailModifier(Slider slider)
|
|
{
|
|
clouds.highFreqModifier = slider.value;
|
|
}
|
|
|
|
public void OnChangeCoverage(Slider slider)
|
|
{
|
|
clouds.coverage = slider.value;
|
|
}
|
|
|
|
public void OnChangeHighCloudsCoverage(Slider slider)
|
|
{
|
|
clouds.coverageHigh = slider.value;
|
|
}
|
|
|
|
public void OnChangeAmbientFactor(Slider slider)
|
|
{
|
|
clouds.ambientLightFactor = slider.value;
|
|
}
|
|
|
|
public void OnChangeDirectFactor(Slider slider)
|
|
{
|
|
clouds.sunLightFactor = slider.value;
|
|
}
|
|
|
|
public void OnChangeHGForward(Slider slider)
|
|
{
|
|
clouds.henyeyGreensteinGForward = slider.value;
|
|
}
|
|
|
|
public void OnChangeHGBackward(Slider slider)
|
|
{
|
|
clouds.henyeyGreensteinGBackward = slider.value;
|
|
}
|
|
|
|
public void OnChangeOpticalDensity(Slider slider)
|
|
{
|
|
clouds.density = slider.value;
|
|
}
|
|
|
|
public void OnChangeLightStepLength(Slider slider)
|
|
{
|
|
clouds.lightStepLength = slider.value;
|
|
}
|
|
|
|
public void OnChangeConeRadius(Slider slider)
|
|
{
|
|
clouds.lightConeRadius = slider.value;
|
|
}
|
|
|
|
public void ToggleRandomSphere()
|
|
{
|
|
clouds.randomUnitSphere = !clouds.randomUnitSphere;
|
|
}
|
|
|
|
public void ToggleExtraLightSamples()
|
|
{
|
|
clouds.aLotMoreLightSamples = !clouds.aLotMoreLightSamples;
|
|
}
|
|
|
|
public void OnChangeNoiseSpeed(Slider slider)
|
|
{
|
|
clouds.windSpeed = slider.value;
|
|
}
|
|
|
|
public void OnChangeNoiseDirection(Slider slider)
|
|
{
|
|
clouds.windDirection = slider.value;
|
|
}
|
|
|
|
public void OnChangeWeatherSpeed(Slider slider)
|
|
{
|
|
clouds.coverageWindSpeed = slider.value;
|
|
}
|
|
|
|
public void OnChangeWeatherDirection(Slider slider)
|
|
{
|
|
clouds.coverageWindDirection = slider.value;
|
|
}
|
|
|
|
public void OnChangeHighCloudsSpeed(Slider slider)
|
|
{
|
|
clouds.highCloudsWindSpeed = slider.value;
|
|
}
|
|
|
|
public void OnChangeHighCloudsDirection(Slider slider)
|
|
{
|
|
clouds.highCloudsWindDirection = slider.value;
|
|
}
|
|
|
|
public void OnChangeGlobalMultiplier(Slider slider)
|
|
{
|
|
clouds.globalMultiplier = slider.value;
|
|
}
|
|
|
|
public void OnChangeWeatherChangeDuration(Slider slider)
|
|
{
|
|
weather.blendTime = slider.value;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
SelectPanel(0);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
{
|
|
quitButton.SetActive(!quitButton.activeSelf);
|
|
}
|
|
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
|
|
float num = 1f / deltaTime;
|
|
fpsText.text = "FPS: " + num;
|
|
}
|
|
}
|
|
}
|