SHARE
TWEET

Untitled

a guest Aug 19th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public float fadeSpeed = 1.5f;            // Speed that the screen fades to and from white.
  2.     private bool sceneStarting = true;        // Whether or not the scene is still fading in.
  3.  
  4.     public Color transparent;
  5.  
  6.     void Awake()
  7.     {
  8.         // Set the texture so that it is the the size of the screen and covers it.
  9.         GetComponent<GUITexture>().pixelInset = new Rect(0f, 0f, Screen.width, Screen.height);
  10.  
  11.         transparent = Color.black;
  12.         transparent.a = 0f;
  13.     }
  14.  
  15.     void Update()
  16.     {
  17.         // If the scene is starting...
  18.         if (sceneStarting)
  19.             // ... call the StartScene function.
  20.             StartScene();
  21.     }
  22.  
  23.  
  24.     void FadeToClear()
  25.     {
  26.         // Lerp the colour of the texture between itself and transparent.
  27.         GetComponent<GUITexture>().color = Color.Lerp(GetComponent<GUITexture>().color, transparent, fadeSpeed * Time.deltaTime);
  28.     }
  29.  
  30.  
  31.     public void FadeToWhite()
  32.     {
  33.         // Lerp the colour of the texture between itself and white.
  34.         GetComponent<GUITexture>().color = Color.Lerp(GetComponent<GUITexture>().color, Color.black, fadeSpeed * Time.deltaTime);
  35.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top