Advertisement
obernardovieira

[Unity3D] Menu Pause

Oct 28th, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2.  
  3. var largura = Screen.width/4;
  4. var altura = Screen.height/4;
  5.  
  6. function Start () {
  7.     Screen.showCursor = false;
  8. }
  9. function Update () {
  10.     if(Input.GetKeyDown(KeyCode.Escape)) {
  11.         doPauseToggle();
  12.     }
  13. }
  14. function OnGUI() {
  15.     if(Time.timeScale == 0) {
  16.         GUI.Box(Rect(largura,altura,largura*6,altura*4),"Pause Menu");
  17.     }
  18. }
  19. function doPauseToggle() {
  20.     if(Time.timeScale > 0) {
  21.         Time.timeScale = 0;
  22.         Screen.showCursor = true;
  23.     }
  24.     else {
  25.         Time.timeScale = 1;
  26.         Screen.showCursor = false;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement