using UnityEngine; using UnityEngine.UI; public class LightBlink : MonoBehaviour { public Image lightImage; // 灯光图片 public float blinkSpeed; // 闪烁速度 private void Update() { if (lightImage != null) { // 通过正弦波计算透明度,值在0到1之间波动 float alpha = Mathf.Abs(Mathf.Sin(Time.time * blinkSpeed)); Color color = lightImage.color; color.a = alpha; // 修改透明度 lightImage.color = color; } } }