C# 我不能让这个暂停菜单统一工作

C# 我不能让这个暂停菜单统一工作,c#,visual-studio,unity3d,debugging,C#,Visual Studio,Unity3d,Debugging,我想 我想我做的每件事都是对的,但它什么也没做,然后我点击了退出按钮 using System.Collections.Generic; using UnityEngine; public class PauseMenu : MonoBehaviour { public static bool GameIsPaused = false; public GameObject pauseMenuUI; // Update is called once per frame

我想

我想我做的每件事都是对的,但它什么也没做,然后我点击了退出按钮

using System.Collections.Generic;
using UnityEngine;

public class PauseMenu : MonoBehaviour
{
    public static bool GameIsPaused = false;

    public GameObject pauseMenuUI;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape)) 
        {
            if (GameIsPaused) 
            {
                Resume();
            }else 
            {
                Pause();
            }
        }
    }

    public void Resume() 
    {
        pauseMenuUI.SetActive(false);
        Time.timeScale = 1f;
        GameIsPaused = false;
    }

    void Pause()
    {
        pauseMenuUI.SetActive(true);
        Time.timeScale = 0f;
        GameIsPaused = true;
    }

    public void LoadMenu()
    {
        Debug.Log("loading menu");
    }

    public void QuitGame()
    {
        Debug.Log("quiting game");
    }
}

它以前在画布上,但我移动了它,因为我试图使它工作,但它没有帮助
有人可能知道如何修复它?

UI组件需要是画布的子级才能成为渲染器。我把面板放在画布下,但它不起作用。如果你不把它放在画布下,比例会变得混乱。确保变换组件上的位置为0,0,0,比例为1,1,1。您确定脚本的引用在inspector中分配正确吗?哪个是分配的引用?因为我可以看到你的箭头指向一个启用的父对象,而只有禁用的子对象。。。。你可能只是启用和禁用了错误的对象吗?嗯,我想我重新观看了视频,我想我不知怎么修复了它,也许我没有放置面板?好了,现在它开始工作了,谢谢