_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Battle_Royale/LightBlink.cs
2024-11-21 20:36:16 +08:00

20 lines
511 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}
}