using UnityEngine.Rendering; namespace UnityEngine.AzureSky { [ExecuteInEditMode] [AddComponentMenu("Azure[Sky]/Azure Environment Controller")] public class AzureEnvironmentController : MonoBehaviour { public ReflectionProbe reflectionProbe; public AzureReflectionProbeState state = AzureReflectionProbeState.Off; public ReflectionProbeRefreshMode refreshMode; public ReflectionProbeTimeSlicingMode timeSlicingMode = ReflectionProbeTimeSlicingMode.NoTimeSlicing; public bool updateAtFirstFrame = true; public float refreshInterval = 2f; private float m_timeSinceLastProbeUpdate; public float environmentIntensity = 1f; public Color environmentAmbientColor = Color.white; public Color environmentEquatorColor = Color.white; public Color environmentGroundColor = Color.white; private void Awake() { if (state == AzureReflectionProbeState.On && refreshMode == ReflectionProbeRefreshMode.ViaScripting && updateAtFirstFrame) { reflectionProbe.RenderProbe(); } } private void Update() { RenderSettings.ambientIntensity = environmentIntensity; RenderSettings.ambientLight = environmentAmbientColor; RenderSettings.ambientSkyColor = environmentAmbientColor; RenderSettings.ambientEquatorColor = environmentEquatorColor; RenderSettings.ambientGroundColor = environmentGroundColor; if (!Application.isPlaying || state != AzureReflectionProbeState.On) { return; } if (refreshMode == ReflectionProbeRefreshMode.EveryFrame) { reflectionProbe.RenderProbe(); } else if (refreshMode == ReflectionProbeRefreshMode.ViaScripting) { m_timeSinceLastProbeUpdate += Time.deltaTime; if (m_timeSinceLastProbeUpdate >= refreshInterval) { reflectionProbe.RenderProbe(); m_timeSinceLastProbeUpdate = 0f; } } } public void UpdateReflectionProbe() { reflectionProbe.RenderProbe(); } } }