Files
2026-06-22 16:18:34 +02:00

41 lines
1.2 KiB
C#

using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace Ashwild.Settings
{
[RequireComponent(typeof(Volume))]
public class BrightnessController : MonoBehaviour
{
[SerializeField] private Volume volume;
private ColorAdjustments colorAdjustments;
private void Awake()
{
if (volume == null) volume = GetComponent<Volume>();
if (volume != null && volume.profile != null)
volume.profile.TryGet(out colorAdjustments);
}
private void OnEnable()
{
if (SettingsManager.Instance != null)
SettingsManager.Instance.onSettingsChanged.AddListener(Apply);
Apply();
}
private void OnDisable()
{
if (SettingsManager.Instance != null)
SettingsManager.Instance.onSettingsChanged.RemoveListener(Apply);
}
private void Apply()
{
if (colorAdjustments == null || SettingsManager.Instance == null) return;
colorAdjustments.postExposure.value = (SettingsManager.Instance.Brightness - 1f) * 2f;
}
}
}