41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
public class Blink : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
public float blinkSpeed = 5;//<2F><>˸<EFBFBD>ٶ<EFBFBD>
|
|||
|
|
private float timer;//<2F><>ʱ<EFBFBD><CAB1>
|
|||
|
|
public float timeval = 1;//ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
private Image img;//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ
|
|||
|
|
public bool isAddAlpha;
|
|||
|
|
private void Start()
|
|||
|
|
{
|
|||
|
|
img = GetComponent<Image>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Update()
|
|||
|
|
{
|
|||
|
|
timer += Time.deltaTime;
|
|||
|
|
if (isAddAlpha)
|
|||
|
|
{
|
|||
|
|
img.color += new Color(0, 0, 0, Time.deltaTime * blinkSpeed);
|
|||
|
|
if (timer >= timeval)
|
|||
|
|
{
|
|||
|
|
img.color = new Color(img.color.r, img.color.g, img.color.b, 1);
|
|||
|
|
isAddAlpha = false;
|
|||
|
|
timer = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
img.color -= new Color(0, 0, 0, Time.deltaTime * blinkSpeed);
|
|||
|
|
if (timer >= timeval)
|
|||
|
|
{
|
|||
|
|
img.color = new Color(img.color.r, img.color.g, img.color.b, 0);
|
|||
|
|
isAddAlpha = true;
|
|||
|
|
timer = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|