unity3d的图片淡入淡出代码

来源:互联网 发布:sql server 2008注册码 编辑:程序博客网 时间:2024/05/16 15:05
原文地址:unity3d的图片淡入淡出代码作者:amiliar

using UnityEngine;
using System.Collections;

public class SimpleFadeOut : MonoBehaviour {

public Texture2D blackScreen;
public float fadeOutTime = 2f;
float fadeOutTimer = 0f;
void Start () {
}
void Update () {
if (fadeOutTimer >= 0&& fadeOutTimer <fadeOutTime) {
fadeOutTimer += Time.deltaTime;
}
}
void OnGUI() {
if (fadeOutTimer < fadeOutTime) {
GUI.Window(-1,newRect(0,0,Screen.width,Screen.height),OnBlScr,"",newGUIStyle());
GUI.BringWindowToFront(-1);
}
}
void OnBlScr(int index) {
GUI.color = new Color(1,1,1,1 - (fadeOutTimer /fadeOutTime));
GUI.DrawTexture(newRect(0,0,Screen.width,Screen.height),blackScreen);
}
}
0 0
原创粉丝点击