VolumeFogGroup.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UIElements;
  5. namespace FXV
  6. {
  7. [ExecuteInEditMode]
  8. public class VolumeFogGroup : MonoBehaviour
  9. {
  10. [SerializeField]
  11. internal bool controlsColor = false;
  12. [SerializeField]
  13. internal Color fogColor;
  14. [SerializeField]
  15. internal bool controlsFalloffParam = false;
  16. [SerializeField, Range(0.1f, 2.0f)]
  17. internal float falloffParamMultiplier = 1.0f;
  18. [SerializeField]
  19. internal bool controlsLighting = false;
  20. [SerializeField]
  21. internal bool affectedByLights = false;
  22. [SerializeField, Range(0.1f, 2.0f)]
  23. internal float lightScatteringFactor = 1.0f;
  24. [SerializeField, Range(0.0f, 1.0f)]
  25. internal float lightReflectivity = 1.0f;
  26. [SerializeField, Range(0.0f, 1.0f)]
  27. internal float lightTransmission = 0.5f;
  28. List<VolumeFog> controlledFogObjects = new List<VolumeFog>();
  29. internal void RegisterFogObject(VolumeFog fog)
  30. {
  31. controlledFogObjects.Add(fog);
  32. }
  33. internal bool UnregisterFogObject(VolumeFog fog)
  34. {
  35. return controlledFogObjects.Remove(fog);
  36. }
  37. public bool IsControllingColor()
  38. {
  39. return controlsColor;
  40. }
  41. public bool IsControllingFalloffParam()
  42. {
  43. return controlsFalloffParam;
  44. }
  45. public bool IsControllingLighting()
  46. {
  47. return controlsLighting;
  48. }
  49. public bool IsAffectedByLights()
  50. {
  51. return affectedByLights;
  52. }
  53. void Start()
  54. {
  55. if (controlledFogObjects.Count == 0)
  56. {
  57. VolumeFog[] fogs = GetComponentsInChildren<VolumeFog>();
  58. for (int i = 0; i < fogs.Length; i++)
  59. {
  60. fogs[i].TryRegisterInGroup();
  61. }
  62. }
  63. }
  64. void Update()
  65. {
  66. }
  67. private void OnValidate()
  68. {
  69. for (int i = 0; i < controlledFogObjects.Count; i++)
  70. {
  71. controlledFogObjects[i].PrepareFogObject();
  72. }
  73. }
  74. }
  75. }