DemoSceneControls.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. namespace VolumetricFogAndMist2.Demos {
  6. public class DemoSceneControls : MonoBehaviour {
  7. public VolumetricFogProfile[] profiles;
  8. public VolumetricFog fogVolume;
  9. public Text presetNameDisplay;
  10. int index;
  11. void Start() {
  12. SetProfile(index);
  13. }
  14. void Update() {
  15. if (Input.GetKeyDown(KeyCode.F)) {
  16. index++;
  17. if (index >= profiles.Length) index = 0;
  18. SetProfile(index);
  19. }
  20. if (Input.GetKeyDown(KeyCode.T)) {
  21. fogVolume.gameObject.SetActive(!fogVolume.gameObject.activeSelf);
  22. }
  23. }
  24. void SetProfile(int profileIndex) {
  25. // move cloud profiles a bit up
  26. if (profileIndex < 2) {
  27. fogVolume.transform.position = Vector3.up * 25;
  28. } else {
  29. fogVolume.transform.position = Vector3.zero;
  30. }
  31. fogVolume.profile = profiles[profileIndex];
  32. presetNameDisplay.text = "Current fog preset: " + profiles[profileIndex].name;
  33. fogVolume.UpdateMaterialPropertiesNow();
  34. }
  35. }
  36. }