I am having problems with my pause button. I have the GUITexture and varibles set up properly. However, when I press the button on the phone or tablet, I have to hold it to pause the game. I would like to press the button to stop the game and then press it again to start the game. Code (csharp): var pauseButton : GUITexture; function Update() { for(var touch : Touch in Input.touches) if(touch.phase==TouchPhase.Began guiTexture.HitTest(touch.position)) { // if(GUI.Button(Rect(200,0,200,39),"Pause Button" )) doPauseToggle(); } else if(touch.phase==TouchPhase.Ended guiTexture.HitTest) { unPauseGame(); } // GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, Vector3(Screen.width / 600.0, Screen.height / 450.0, 1)); // Draw player blip (centerObject) // bX=centerObject.transform.position.x * mapScale; // bY=centerObject.transform.position.z * mapScale; // GUI.DrawTexture(Rect(mapCenter.x - mapWidth/2,mapCenter.y-mapHeight/2,mapWidth,mapHeight),pauseButton); // Draw blips for Enemies // DrawBlipsForEnemies(); } function doPauseToggle() { if(Time.timeScale > 0) { pauseGame(); } else{ unPauseGame(); } } function pauseGame() { Time.timeScale = 0; } function unPauseGame() { Time.timeScale = 1; }
I don't know if it gonna works but you need do in your button something like this var control:boolean; if touchphase==touch.began: if (control==true) control=false; PauseGame(); else control=true; unPause()