1,创建个对象命名为screenFader,x:0.5,y:0.5,添加组件Rendering->GUI Texture,将Texture文件夹中的swatch_black_dff拖入Texture属性栏中,将Pixel Inset都设为0
2,为screenFader添加脚本DoneSceneFadeInOut
using UnityEngine;
using System.Collections;
public class DoneSceneFadeInOut : MonoBehaviour
{
public float fadeSpeed = 1.5f;// Speed that the screen fades to and from black.
private bool sceneStarting = true;// Whether or not the scene is still fading in.
void Awake ()
{
// Set the texture so that it is the size of the screen and covers it.
guiTexture.pixelInset = new Rect(0f, 0f, Screen.width, Screen.height);
}
void Update ()
{
// If the scene is starting...
if(sceneStarting)
// ... call the StartScene function.
StartScene();
}
void FadeToClear ()
{
// Lerp the colour of the texture between itself and transparent.
guiTexture.color = Color.Lerp(guiTexture.color, Color.clear, fade