81 lines
2.1 KiB
C#
81 lines
2.1 KiB
C#
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
|
|
namespace VolumetricFogAndMist
|
|
{
|
|
public class DemoWalk : MonoBehaviour
|
|
{
|
|
private void Start()
|
|
{
|
|
GameObject gameObject = GameObject.Find("Elephant");
|
|
gameObject.GetComponent<Renderer>().shadowCastingMode = ShadowCastingMode.On;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
VolumetricFog instance = VolumetricFog.instance;
|
|
if (Input.GetKeyDown(KeyCode.F))
|
|
{
|
|
switch (instance.preset)
|
|
{
|
|
case FOG_PRESET.Clear:
|
|
case FOG_PRESET.Custom:
|
|
instance.preset = FOG_PRESET.Mist;
|
|
break;
|
|
case FOG_PRESET.Mist:
|
|
instance.preset = FOG_PRESET.WindyMist;
|
|
break;
|
|
case FOG_PRESET.WindyMist:
|
|
instance.preset = FOG_PRESET.GroundFog;
|
|
break;
|
|
case FOG_PRESET.GroundFog:
|
|
instance.preset = FOG_PRESET.FrostedGround;
|
|
break;
|
|
case FOG_PRESET.FrostedGround:
|
|
instance.preset = FOG_PRESET.FoggyLake;
|
|
break;
|
|
case FOG_PRESET.FoggyLake:
|
|
instance.preset = FOG_PRESET.Fog;
|
|
break;
|
|
case FOG_PRESET.Fog:
|
|
instance.preset = FOG_PRESET.HeavyFog;
|
|
break;
|
|
case FOG_PRESET.HeavyFog:
|
|
instance.preset = FOG_PRESET.LowClouds;
|
|
break;
|
|
case FOG_PRESET.LowClouds:
|
|
instance.preset = FOG_PRESET.SeaClouds;
|
|
break;
|
|
case FOG_PRESET.SeaClouds:
|
|
instance.preset = FOG_PRESET.Smoke;
|
|
break;
|
|
case FOG_PRESET.Smoke:
|
|
instance.preset = FOG_PRESET.ToxicSwamp;
|
|
break;
|
|
case FOG_PRESET.ToxicSwamp:
|
|
instance.preset = FOG_PRESET.SandStorm1;
|
|
break;
|
|
case FOG_PRESET.SandStorm1:
|
|
instance.preset = FOG_PRESET.SandStorm2;
|
|
break;
|
|
case FOG_PRESET.SandStorm2:
|
|
instance.preset = FOG_PRESET.Mist;
|
|
break;
|
|
}
|
|
}
|
|
else if (Input.GetKeyDown(KeyCode.T))
|
|
{
|
|
instance.enabled = !instance.enabled;
|
|
}
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
Rect position = new Rect(10f, 10f, Screen.width - 20, 30f);
|
|
GUI.Label(position, "Move around with WASD or cursor keys, space to jump, F key to change fog style, T to toggle fog on/off.");
|
|
position = new Rect(10f, 30f, Screen.width - 20, 30f);
|
|
GUI.Label(position, "Current fog preset: " + VolumetricFog.instance.GetCurrentPresetName());
|
|
}
|
|
}
|
|
}
|