krippenspiele/Assets/HintergrundfarbeAnpassen.cs

29 lines
859 B
C#

using UnityEngine;
using UnityEngine.Rendering.Universal;
public class HintergrundfarbeAnpassen : MonoBehaviour
{
public GameObject globalLight;
private Light2D lightComponent;
private Camera cameraComponent;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
lightComponent = globalLight.GetComponent<Light2D>();
cameraComponent = GetComponent<Camera>();
}
// Update is called once per frame
void Update()
{
}
// LateUpdate is called once per frame after all Update-methods
void LateUpdate()
{
// The background color should always adapt to the intensity of the global light.
float value = lightComponent.intensity;
cameraComponent.backgroundColor = new Color(value, value, value);
}
}