Unity C# 代码实现图片颜色交替变化 (绿色和黑色)
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class shouTime : MonoBehaviour { public Image duanLuQi; public float changeTime = 0.25f; private float timer; private bool isDisplay = true;
void Update()
{
effect();
}
void effect()
{
timer += Time.deltaTime;
if (timer >= changeTime)
{
timer -= changeTime;
if (isDisplay)
{
duanLuQi.color = Color.black;
isDisplay = false;
}
else
{
duanLuQi.color = Color.green;
isDisplay = true;
}
}
}
}
原文地址: https://www.cveoy.top/t/topic/oakx 著作权归作者所有。请勿转载和采集!