Files
XMen/Assets/Scripts/LightFade.cs
2025-07-10 14:49:53 +08:00

35 lines
843 B
C#

using UnityEngine;
public class LightFade : MonoBehaviour
{
public MeshRenderer[] meshRenderers;
public float minIntensity = 0.0f;
public float maxIntensity = 1.0f;
public float fadeSpeed = 1.0f;
private float currentIntensity;
private void Start()
{
currentIntensity = minIntensity;
}
private void Update()
{
if (currentIntensity >= maxIntensity)
{
fadeSpeed = -1.0f;
}
else if (currentIntensity <= minIntensity)
{
fadeSpeed = 1.0f;
}
currentIntensity += fadeSpeed * Time.deltaTime;
// for (int i = 0; i < meshRenderers.Length; i++)
// {
// meshRenderers[i].material.SetColor("_EmissionColor", new Color(currentIntensity, currentIntensity, currentIntensity));
// }
}
}