张银爱吧 关注:4贴子:64
  • 0回复贴,共1

我是来背代码的

只看楼主收藏回复

using UnityEngine;
using System.Collections;
public class ScreenFaderInOut : MonoBehaviour
{
public float fadeSpeed = 1.5f;
private bool sceneStarting = true;
void Awake()
{
GetComponent<GUITexture>().pixelInset = new Rect (0f, 0f, Screen.width, Screen.height);
}
void Update()
{
if (sceneStarting)
{
StartScene();
}
}
void FadeToClear()
{
GetComponent<GUITexture>().color = Color.Lerp (GetComponent<GUITexture>().color, Color.clear, fadeSpeed * Time.deltaTime);
}
void FadeToBlack()
{
GetComponent<GUITexture>().color = Color.Lerp (GetComponent<GUITexture>().color, Color.black, fadeSpeed * Time.deltaTime);
}
void StartScene()
{
FadeToClear ();
if (GetComponent<GUITexture>().color.a <= 0.05f)
{
GetComponent<GUITexture>().color = Color.clear;
GetComponent<GUITexture>().enabled = false;
sceneStarting = false;
}
}
public void EndScene()
{
GetComponent<GUITexture>().enabled = true;
FadeToBlack ();
if (GetComponent<GUITexture>().color.a >= 0.95f)
{
Application.LoadLevel (1);
}
}
}


IP属地:广东1楼2015-04-24 13:14回复