topical media & game development

talk show tell print

lib-unity-book-09-FadeTexture.js / js



  var theTexture : Texture2D;
  private var StartTime : float;
  
  function OnLevelWasLoaded(){
          StartTime = Time.time;
  }
  
  function Update () {
          if(Time.time-StartTime >= 3){
                  Destroy(gameObject);   
          }
  }      
           
  function OnGUI(){
                  GUI.color = Color.white;
                  GUI.color.a = Mathf.Lerp(1.0, 0.0, (Time.time-StartTime));
                  GUI.DrawTexture(Rect( 0, 0, Screen.width, Screen.height ), theTexture);
  }
          
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.