41 lines
1005 B
C#
41 lines
1005 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class EmissiveLightMatching : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private List<int> indexes;
|
|
private List<Color> colors= new List<Color>();
|
|
[SerializeField]
|
|
private Light reference;
|
|
private float initIntensity;
|
|
|
|
private void Awake()
|
|
{
|
|
initIntensity = reference.intensity;
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
foreach(int index in indexes) {
|
|
colors.Add(this.gameObject.GetComponent<MeshRenderer>().materials[index].GetColor("_EmissiveColor"));
|
|
}
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
int x = 0;
|
|
foreach(int i in indexes)
|
|
{
|
|
|
|
this.gameObject.GetComponent<MeshRenderer>().materials[i].SetColor("_EmissiveColor", colors[x] * ((10*reference.intensity / initIntensity)));
|
|
x++;
|
|
}
|
|
|
|
}
|
|
}
|