43 lines
945 B
C#
43 lines
945 B
C#
using Obvious.Soap;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
using UnityEngine.Rendering.HighDefinition;
|
|
|
|
public class GlobalVolumeController : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Volume globalVolume;
|
|
|
|
[SerializeField]
|
|
private VolumeProfile _volumeProfile;
|
|
|
|
public FloatVariable timeOfDay;
|
|
|
|
public FloatVariable rainingPreset;
|
|
|
|
public AnimationCurve dayFog;
|
|
|
|
public AnimationCurve rainingFog;
|
|
|
|
private Fog _fog;
|
|
|
|
private CloudLayer _cloudLayer;
|
|
|
|
private void Update()
|
|
{
|
|
float x = dayFog.Evaluate(timeOfDay.Value) + rainingFog.Evaluate(rainingPreset.Value);
|
|
if (_volumeProfile != null && _volumeProfile.TryGet<Fog>(out var component))
|
|
{
|
|
component.meanFreePath.Override(x);
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
_volumeProfile = Object.Instantiate(globalVolume.profile);
|
|
globalVolume.sharedProfile = _volumeProfile;
|
|
_volumeProfile.TryGet<Fog>(out _fog);
|
|
_volumeProfile.TryGet<CloudLayer>(out _cloudLayer);
|
|
}
|
|
}
|