using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ffff : MonoBehaviour {
private float minAlpha = 0.0f;
private float maxAlpha = 0.9f;
private float curAlpha = 1.0f;
private float nextAlpha = 0.0f;
float varifySpeed = 1f;
public Image go;
// Use this for initialization
void Start () {
go = this.gameObject.GetComponent<Image>();
}
// Update is called once per frame
void Update () {
transform.Translate(new Vector3(40, 50) * 3 * Time.deltaTime, Space.World);
Trans();
}
private void Trans()
{
curAlpha += Time.deltaTime * varifySpeed * (-1);//当前物体逐渐消失
Color c = go.color;
curAlpha = Mathf.Clamp(curAlpha, minAlpha, maxAlpha);
c.a = curAlpha;
go.color = c;
//Debug.Log(c.ToString());
}
}
控制Alpha通道,实现透明度逐渐消失
最新推荐文章于 2024-03-11 13:00:00 发布