Files
UltimateFishing2020/Assets/Scripts/Assembly-CSharp/AGGlobalSnow.cs
2026-03-04 10:03:45 +08:00

93 lines
2.1 KiB
C#

using UnityEngine;
[DisallowMultipleComponent]
[ExecuteInEditMode]
[RequireComponent(typeof(MeshRenderer))]
public class AGGlobalSnow : MonoBehaviour
{
[Header("Global Wind")]
public bool EnableGlobalWind = true;
private float WindToggle;
[Range(0f, 1f)]
public float WindGrassAmplitude = 0.5f;
[Range(0f, 10f)]
public float WindGrassSpeed = 4f;
[Range(0f, 3f)]
public float WindGrassScale = 0.5f;
[Range(0f, 1f)]
public float WindGrassStiffness = 0.5f;
[Header("Tint Color")]
public bool EnableTintColor = true;
private float TintToggle;
public Texture2D TintNoiseTexture;
[Range(0.001f, 10f)]
public float TintNoiseTile = 1f;
[Range(0.001f, 10f)]
public float TintNoiseContrast = 1f;
[Range(0f, 1f)]
[Header("Global Snow for Props")]
public float SnowPropsIntensity = 1f;
[Range(0f, 1f)]
public float SnowPropsOffset = 1f;
[Range(0f, 1f)]
public float SnowPropsContrast = 1f;
private void Awake()
{
if (Application.isPlaying)
{
base.gameObject.GetComponent<MeshRenderer>().enabled = false;
}
else
{
base.gameObject.GetComponent<MeshRenderer>().enabled = true;
}
}
private void Update()
{
if (EnableGlobalWind)
{
WindToggle = 1f;
}
else
{
WindToggle = 0f;
}
if (EnableTintColor)
{
TintToggle = 1f;
}
else
{
TintToggle = 0f;
}
Shader.SetGlobalVector("AGW_WindDirection", base.gameObject.transform.forward);
Shader.SetGlobalFloat("AGW_WindToggle", WindToggle);
Shader.SetGlobalFloat("AGW_WindGrassAmplitude", WindGrassAmplitude);
Shader.SetGlobalFloat("AGW_WindGrassSpeed", WindGrassSpeed);
Shader.SetGlobalFloat("AGW_WindGrassScale", WindGrassScale);
Shader.SetGlobalFloat("AGW_WindGrassStiffness", WindGrassStiffness);
Shader.SetGlobalTexture("AG_TintNoiseTexture", TintNoiseTexture);
Shader.SetGlobalFloat("AG_TintToggle", TintToggle);
Shader.SetGlobalFloat("AG_TintNoiseTile", TintNoiseTile);
Shader.SetGlobalFloat("AG_TintNoiseContrast", TintNoiseContrast);
Shader.SetGlobalFloat("AGP_SnowIntensity", SnowPropsIntensity);
Shader.SetGlobalFloat("AGP_SnowOffset", SnowPropsOffset);
Shader.SetGlobalFloat("AGP_SnowContrast", SnowPropsContrast);
}
}