using UnityEngine; using System.Collections.Generic; using UnityEngine.Rendering.HighDefinition; public class LightAnimationManager : MonoBehaviour { private HDAdditionalLightData additionalLightData; private MaterialEmissionOverride matBlockHandler; private float _oldValue; //private LightEventAnimation[] lightAnimations; private List lightAnimations = new List(); private void OnEnable() { //lightAnimations = GetComponents(); if (gameObject.GetComponent()) additionalLightData = gameObject.GetComponent(); else if (gameObject.GetComponent()) matBlockHandler = gameObject.GetComponent(); } public void RegisterEvent(LightEventAnimation lightEvent) { lightAnimations.Add(lightEvent); } void Update() { if (additionalLightData == null && matBlockHandler == null) return; if (lightAnimations.Count <= 0) return; var currentValue = 1.0f; foreach (var lightAnimator in lightAnimations) { currentValue *= lightAnimator.getCurrentValue(); } //if( _oldValue != currentValue ) //{ if (matBlockHandler != null) matBlockHandler.emissiveDimmer = currentValue; else if (additionalLightData != null) additionalLightData.lightDimmer = currentValue; _oldValue = currentValue; //} } public void SetDimmer(float dimmer) { OnEnable(); if (matBlockHandler != null) matBlockHandler.emissiveDimmer = dimmer; if (additionalLightData != null) additionalLightData.lightDimmer = dimmer; } }