This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/Scripts/Enviornment/EmissiveLightMatching.cs

36 lines
942 B
C#
Raw Normal View History

using System.Collections.Generic;
using UnityEngine;
public class EmissiveLightMatching : MonoBehaviour
{
2023-06-01 17:03:48 +02:00
[SerializeField] private List<int> indexes;
[SerializeField] private Light reference;
private readonly List<Color> colors = new();
private float initIntensity;
private void Awake()
{
initIntensity = reference.intensity;
}
2023-06-01 17:03:48 +02:00
// Start is called before the first frame update
2023-06-01 17:03:48 +02:00
private void Start()
{
2023-06-01 17:03:48 +02:00
foreach (var index in indexes)
colors.Add(gameObject.GetComponent<MeshRenderer>().materials[index].GetColor("_EmissiveColor"));
}
2023-06-01 17:03:48 +02:00
// Update is called once per frame
2023-06-01 17:03:48 +02:00
private void Update()
{
2023-06-01 17:03:48 +02:00
var x = 0;
foreach (var i in indexes)
{
2023-06-01 17:03:48 +02:00
gameObject.GetComponent<MeshRenderer>().materials[i].SetColor("_EmissiveColor",
colors[x] * (10 * reference.intensity / initIntensity));
x++;
}
}
2023-06-01 17:03:48 +02:00
}