46 lines
937 B
C#
46 lines
937 B
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering.HighDefinition;
|
|
using UnityEngine.VFX;
|
|
|
|
[ExecuteInEditMode]
|
|
public class WaterSurfaceBindVFX : MonoBehaviour
|
|
{
|
|
public WaterSurface waterSurface;
|
|
|
|
public bool active { get; private set; }
|
|
|
|
public VisualEffect[] visualEffects { get; private set; }
|
|
|
|
private void OnEnable()
|
|
{
|
|
visualEffects = base.gameObject.GetComponentsInChildren<VisualEffect>(includeInactive: true);
|
|
UpdateActive(newActive: false);
|
|
}
|
|
|
|
private void UpdateActive(bool newActive)
|
|
{
|
|
active = newActive;
|
|
VisualEffect[] array = visualEffects;
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
array[i].enabled = newActive;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
bool flag = waterSurface != null && waterSurface.SetGlobalTextures();
|
|
if (flag != active)
|
|
{
|
|
UpdateActive(flag);
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
UpdateActive(newActive: false);
|
|
visualEffects = Array.Empty<VisualEffect>();
|
|
}
|
|
}
|