Answers for "Unity Pause Game c#"

C#
0

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
Posted by: Guest on October-06-2021
0

Unity Pause Game c#

void PauseGame ()
    {
        Time.timeScale = 0f;
        AudioListener.pause = true;
    }

void ResumeGame ()
    {
        Time.timeScale = 1;
        AudioListener.pause = false;
    }Copy
Posted by: Guest on October-06-2021

C# Answers by Framework

Browse Popular Code Answers by Language