This is from my snippets I’ve written when I was testing HDRP, should work:
(Attach it to an object with your Gradient Sky, it should then change the colors of the Gradient Sky when your enter the play mode.)
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
public class AccessVolumeOverrideSky : MonoBehaviour
{
VisualEnvironment visualEnvironment;
GradientSky gradientSky;
void Awake()
{
Volume volume = gameObject.GetComponent<Volume>();
VisualEnvironment tempVis;
if (volume.profile.TryGet<VisualEnvironment>(out tempVis)) {
visualEnvironment = tempVis;
}
GradientSky tempGradSky;
if (volume.profile.TryGet<GradientSky>(out tempGradSky)) {
gradientSky = tempGradSky;
}
// Set the sky type
visualEnvironment.skyType.value = (int)SkyType.Gradient;
// Set the sky parameters
gradientSky.top.value = Color.red;
gradientSky.middle.value = Color.green;
gradientSky.bottom.value = Color.blue;
gradientSky.gradientDiffusion.value = 2.0f;
}
}
EDIT: Misread your message a bit, but it should be possible to update the gradient values in Update too, just try this, should work too: