Unity3D 暂停游戏并出现暂停菜单

关键代码:

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            canvas.enabled = !canvas.enabled;
            Pause();
        }
    }

    public void Pause()
    {
        Time.timeScale = Time.timeScale == 0 ? 1 : 0;
        
    }

你可能感兴趣的:(Unity3D 暂停游戏并出现暂停菜单)