我希望重启按钮在游戏结束后仍能正常工作,而不仅仅是在游戏进行期间。游戏期间该按钮在那里(可见),但仅在游戏期间可用。每当“ gameon是false时,按钮就会停止工作。我只是在学习如何编写代码,因此,如果这太明显了,我感到抱歉。
我试图使RestartGame()成为if语句。
public void GameOver()
{
gameon = false;
gameOverText.gameObject.Setactive(true);
restartButton.gameObject.Setactive(true);
}
public void RestartGame()
{
SceneManager.LoadScene(SceneManager.GetactiveScene().name);
}
可以在游戏过程中重新启动游戏,但不能在游戏结束后重新启动游戏。