using System.Collections; using System.Collections.Generic; using UnityEngine; public class LightInteractableData : MonoBehaviour { public List lightRenderers; public List lightMaterials; public List emissionColors; public List emissiveExposureWeight; public List isEmissiveMaterial; private void Awake() { foreach (var _lightRenderers in lightRenderers) { foreach (var material in _lightRenderers.materials) { Color currentEmissiveColor = material.GetColor("_EmissiveColor"); // Check if the emissive color is larger than (0, 0, 0, 255) if (currentEmissiveColor.r > 0 && currentEmissiveColor.g > 0 && currentEmissiveColor.b > 0 && currentEmissiveColor.a > 0) { emissionColors.Add(currentEmissiveColor); emissiveExposureWeight.Add(1f); isEmissiveMaterial.Add(true); } else { emissionColors.Add(currentEmissiveColor); emissiveExposureWeight.Add(-100f); isEmissiveMaterial.Add(false); } } } } public void UpdateLightEmissionAndExposureWeightOnRuntime() { foreach (var lightRenderer in lightRenderers) { foreach (var material in lightRenderer.materials) { for (int i = 0; i < emissionColors.Count; i++) { Color currentEmissiveColor = material.GetColor("_EmissiveColor"); if (currentEmissiveColor.r > 0 && currentEmissiveColor.g > 0 && currentEmissiveColor.b > 0 && currentEmissiveColor.a > 0) { // Debugging print statement to verify the assignment print($"Assigning emissive color to emissionColors[{i}]"); emissionColors[i] = currentEmissiveColor; print("Updated Light emission and exposure weight on runtime!"); } else { // Debugging print statement to verify the condition is met print("Skipped due to zero emissive color."); i++; //continue; } } } } } public void UpdateLightEmissionAndExposureWeightOnRuntimeBasedOnIndices(int lampRendererMaterialIndices) { foreach (Renderer lightRenderer in lightRenderers) { Material[] materials = lightRenderer.materials; Color currentEmissiveColor = materials[lampRendererMaterialIndices].GetColor("_EmissiveColor"); // Debugging print statement to verify the assignment print($"Assigning emissive color to emissionColors[{lampRendererMaterialIndices}]"); emissionColors[lampRendererMaterialIndices] = currentEmissiveColor; print("Updated Light emission and exposure weight on runtime!"); } } }