topical media & game development

talk show tell print

lib-unity-book-08-MainMenuBtns.js / js



  /* Script Provided by Will Goldstone as part of Unity Game Development Essentials book assets */
  /* Please Do Not Remove this comment - this script is for reference only */
  
  var levelToLoad : String;
  var normalTexture : Texture2D;
  var rollOverTexture : Texture2D;
  var beep : AudioClip;
  var QuitButton : boolean = false;
  
  function OnMouseEnter(){
          guiTexture.texture = rollOverTexture;
  }
  function OnMouseExit(){
          guiTexture.texture = normalTexture;        
  }
  
  function OnMouseUp(){
          audio.PlayOneShot(beep);
          yield new WaitForSeconds(0.35);
                  
          if(QuitButton){
                  Application.Quit();
                  Debug.Log("This part works!");
          }
          else{
                  Application.LoadLevel(levelToLoad);        
          }
  }
  
  @script RequireComponent(AudioSource)


(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.