using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; // Assuming URP. Change if using built-in or HDRP. public class BrightnessController : MonoBehaviour { [SerializeField] private Volume postProcessVolume; private ColorAdjustments colorAdjustments; private void Start() { if (postProcessVolume != null && postProcessVolume.profile.TryGet(out colorAdjustments)) { // Successfully found the ColorAdjustments effect } else { Debug.LogError("BrightnessController could not find a Volume with ColorAdjustments.", this); } } /// /// Sets the brightness. /// /// A value from 0 (dark) to 1 (bright). public void SetBrightness(float value) { if (colorAdjustments != null) { // We map the 0-1 slider value to a new exposure range, e.g., -1 to 1.4. colorAdjustments.postExposure.value = Mathf.Lerp(-1f, 1.4f, value); } } }