Unity Pause Game c#
public class PauseControl : MonoBehaviour
{
public static bool gameIsPaused;
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
gameIsPaused = !gameIsPaused;
PauseGame();
}
}
void PauseGame ()
{
if(gameIsPaused)
{
Time.timeScale = 0f;
}
else
{
Time.timeScale = 1;
}
}
}Copy