通过改变unity中物体的alpha值实现若隐若现的效果
RawImage logo = mainLogo.transform.FindChild("back/headBack/Logo").GetComponent<RawImage>();
void Update()
{
var r = logo.color.r;
var g = logo.color.g;
var b = logo.color.b;
var alpha = Mathf.PingPong(Time.time / 5f, 1);
logo.color = new Color(r, g, b, alpha);
}
//在unity简单使用案例
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class fade : MonoBehaviour
{
private Image image;
void Start()
{
image = GameObject.Find("Canvas/Image").GetComponent<Image>();
}
void Update()
{
var r = image.color.r;
var g = image.color.g;
var b = image.color.b;
var alpha = Mathf.PingPong(Time.time / 5f, 1);
image.color = new Color(r, g, b, alpha);
}
}