29 lines
573 B
C#
29 lines
573 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class CanvasGroupBlinker : MonoBehaviour
|
|
{
|
|
public float maxOpacity = 1;
|
|
public float minOpacity = 0.5f;
|
|
public float speed = 1;
|
|
|
|
|
|
CanvasGroup canvasGroup;
|
|
void Awake()
|
|
{
|
|
canvasGroup = GetComponent<CanvasGroup>();
|
|
}
|
|
|
|
float a=0;
|
|
void Update()
|
|
{
|
|
a+=Time.deltaTime;
|
|
|
|
float sinA = Mathf.Sin(a);
|
|
float normalized = (sinA + 1) / 2f;
|
|
|
|
canvasGroup.alpha = Mathf.Lerp(minOpacity,maxOpacity, normalized);
|
|
}
|
|
}
|