Pausing Play on Android
Hey,
So I am in the process of converting my desktop/standalone 2d game build to Android. I am having trouble with the pause functionality. My pause screen is a prefab that is spawned on "p" input for desktop and I would like it to spawn when the player taps the screen again (play is launched by tapping the screen).
Rather than pause when tapped, the UI flashes on screen - I guess this is because it loops through update and cant compute the touchcount.
Is there a way to index the second touch to trigger the pause?!
My code is below.
Thanks in advance
void Play()
{
if (Input.GetMouseButtonDown(0) || Input.touchCount == 1) { //if clicked per standalone OR tapped
gameOn = true;
levelTitle.CrossFadeAlpha(0.0f, 0.5f, false);
}
}
void PausePlay() //pauses game and is triggered when p is clicked { if (Input.GetKeyDown(KeyCode.P) || (Input.touchCount % 2 == 0)) //if p clicked OR taps are divisible by 2
{ if (Time.timeScale == 1) { ShowPaused(); Debug.Log("Paused Game"); } else if (Time.timeScale == 0) { HidePaused(); Debug.Log("Unpaused Game");
}
}
}
This was in the $$anonymous$$ETA section, which is for questions about how the site works. I moved it to the Help Room area (can read the FAQ and the Help Room sticky, if you like.)