You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
839 B
42 lines
839 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class BlinkImg : MonoBehaviour
|
|
{
|
|
private Image _image;
|
|
[SerializeField]
|
|
float _alpha;
|
|
[SerializeField]
|
|
int dir =1;
|
|
[SerializeField]
|
|
private float maxAlpha=0.9f;
|
|
[SerializeField]
|
|
private float minAlpha=0.5f;
|
|
|
|
private void Start()
|
|
{
|
|
_image = GetComponent<Image>();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
|
|
if (_image.color.a >= maxAlpha)
|
|
{
|
|
dir = -1;
|
|
|
|
}
|
|
else if(_image.color.a <= minAlpha)
|
|
{
|
|
dir = 1;
|
|
|
|
}
|
|
_alpha = _image.color.a;
|
|
_alpha += Time.deltaTime * 0.25f * dir;
|
|
_image.color = new Color(_image.color.r, _image.color.g, _image.color.b, _alpha);
|
|
|
|
}
|
|
}
|