如何解决为什么我在 unity c# 中遇到这个错误,我该如何解决?
我正在尝试统一制作一个暂停菜单,但它说我无法公开某个功能。为什么我不能?
它说
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 行的 }
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。