[英]How do I fix error CS0111 in Unity/Vscode?
I'm just starting to learn to develop games in Unity with Vscode, so I found a Brackeys tutorial on it.我刚开始学习用 Vscode 在 Unity 中开发游戏,所以我找到了一个 Brackeys 教程。 I've been watching the series for a while, until I came across an issue;我一直在看这个系列,直到遇到一个问题; I got an error while following along with the 9th episode that says: Assets\Scripts\GameManager.cs(20,6): error CS0111: Type 'GameManager' already defines a member called 'Restart' with the same parameter types跟随第 9 集时出现错误:Assets\Scripts\GameManager.cs(20,6): error CS0111: Type 'GameManager' already defined a member called 'Restart' with the same parameter types
I have tried to figure out the issue based on what the error says, but I couldn't get it to work.我试图根据错误的内容找出问题,但我无法让它工作。 I was hoping someone could help.我希望有人能帮忙。
Here is my code:这是我的代码:
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
bool gameHasEnded = false;
public float restartDelay = 1f;
public void CompleteLevel ()
{Debug.Log ("You did it!");
}
public void EndGame ()
{
if (gameHasEnded == false)
{
gameHasEnded = true;
Debug.Log ("Game Over");
Invoke("Restart", restartDelay);
}
}
void Restart ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
It says that your "Restart'" method has been redefined.它说您的“重新启动”方法已被重新定义。 Try changing the "Restart" method to the "Restarts" method.尝试将“重新启动”方法更改为“重新启动”方法。
void Restarts ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
thank you hope it helps谢谢希望对你有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.