Unity3D - Android pause screen - double click issue

Posted by user3666251 on Game Development See other posts from Game Development or by user3666251
Published on 2014-06-07T10:25:38Z Indexed on 2014/06/07 15:41 UTC
Read the original article Hit count: 290

Filed under:
|
|

I made a pause script for the game im developing for android.

I added the script to the GUITexture I created and placed on the top right side of the screen.The issue stands at the part where if the player clicks the pause button then clicks resume then he wants to pause the game again.When he clicks pause the second time the buttons dont show up unless he clicks again.

This is the script :

#pragma strict

var paused = false;
var isButtonVisible : boolean = true;

function OnMouseDown(){
this.paused = !this.paused;
   Time.timeScale = 0;
           isButtonVisible = true;
}

function OnGUI(){

if ( isButtonVisible ) {
if(this.paused){
    if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2+3,200,50),"Restart")){
Application.LoadLevel(Application.loadedLevel);
Time.timeScale = 1;
    isButtonVisible = false;
    }

    if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2-50,200,50),"Resume")){
Time.timeScale = 1;
    isButtonVisible = false;
}
    // Insert the rest of the pause menu logic

            if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2+56,200,50),"Main Menu")){
            Application.LoadLevel ("MainMenu");
                    isButtonVisible = false;
                    Time.timeScale = 1;
            }

    }
  }
}

Thank you.

© Game Development or respective owner

Related posts about android

Related posts about unity