问题描述
我正在尝试统一制作一个暂停菜单,但它说我无法公开某个功能。为什么我不能?
它说
CS0106 修饰符 'public' 对该项目无效 Assembly-CSharp、Assembly-CSharp.Player C:\Users\Jaspin\CubeGame\Assets\UI\Paused\PauseMenu.cs 47 Active
对于所有三个。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PauseMenu : MonoBehavIoUr
{
public GameObject pauseMenuUI;
public static bool GameIsPaused = false;
void Start()
{
pauseMenuUI.SetActive(false);
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameIsPaused)
{
Resume();
} else
{
Pause();
}
}
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...");
}
}
}
解决方法
您正在使用嵌套函数。 LoadMenu
是 Update
中的嵌套函数。嵌套函数不能有可见性修饰符。
您可能错过了第 32 行的 }
。