Guest User

Movie Fade (Unity3D)

a guest
May 31st, 2012
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var t : float = 0.0;
  2. var currentT : float;
  3. var darken = false;
  4.  
  5. var movie1 : MovieTexture;
  6. var sound1 : AudioSource;
  7.  
  8. var blackImage : Texture2D;
  9.  
  10. var videoPlaying = true;
  11.  
  12. var gui : GUITexture;
  13.  
  14. var colors = [Color.white, Color.black];
  15.  
  16. function Update ()
  17. {
  18.     if(Input.GetKeyDown(KeyCode.Space)) Darken();
  19.     guiTexture.pixelInset = Rect(-Screen.width/2,-Screen.height/2,Screen.width,Screen.height);
  20. }
  21.  
  22. function Darken()
  23. {
  24.     if(videoPlaying)
  25.     {
  26.     videoPlaying = false;
  27.     guiTexture.texture = movie1;
  28.     colors = [Color.white, Color.black];
  29.     yield Fade.use.Alpha(gui.guiTexture, 0.0, 1.0, 2.0, EaseType.InOut);
  30.     movie1.Play(); 
  31.     sound1.Play();
  32.     yield Fade.use.Colors(gui.guiTexture, Color.black, Color(255,255,255), 1.0);
  33.     Time.timeScale=0;
  34.     }
  35.    
  36.     else
  37.     {
  38.     Time.timeScale=1;
  39.     videoPlaying = true;
  40.     movie1.Pause();
  41.     sound1.Pause();
  42.     colors = [Color.white, Color.black];
  43.     yield Fade.use.Colors(gui.guiTexture, Color.white, Color.black, 1.0);
  44.     guiTexture.texture = blackImage;
  45.     yield Fade.use.Alpha(gui.guiTexture, 1.0, 0.0, 2.0, EaseType.InOut);
  46.     yield WaitForSeconds(2.0);
  47.     }
  48. }
Add Comment
Please, Sign In to add comment