【发布时间】:2015-12-27 01:05:45
【问题描述】:
我想制作一个 UI,让玩家可以选择继续玩游戏(关闭菜单)或转到主菜单。该代码之前运行良好,但今天,我将其加载,发现由于我正在处理的脚本不同,我的所有代码都没有编译。所以,我删除了脚本组件,然后再试一次。
我关注了recommended advice listed here,它以前工作过 - 但现在它不工作了。我不知道我做错了什么。附上我拍的一些照片和代码。任何和所有的帮助将不胜感激。
/// <summary>
/// This class controls the 'Resume Game' Button. When the button is pressed, it removes the menu, and allows the game to continue.
/// </summary>
public class ResumeButton : MonoBehaviour {
public bool isPaused = false;
public GameObject menu;
public void ResumeButtonClicked()
{
Time.timeScale = 1;
menu.SetActive(isPaused);
print("It is not paused!");
isPaused = false;
}
public void MainMenuButton()//There is only one button in the scene, this was code I was planning to add in. I am keeping it in here just in case it has any effect on the answer.
{
Application.LoadLevel("TestScene2");
}
}
方法未出现:
【问题讨论】:
-
如果你使用 svn 或 git,回去会容易得多。
-
您是否将 ResumeButton 脚本添加回您的 ButtonController?
-
@Oliver 也许,但事后看来是 20/20。所以,我现在需要专注于解决问题,而不是弄清楚如何为将来保存代码。 JamesHogle 是的,我做到了。没有骰子。
-
如果你没有版本控制系统,我会建立一个新的(空的)项目并开始将部分从不工作的部分复制到香草系统,并在每一步之后检查它是否工作预期的。然后你可能会知道错误在哪里。
-
谢天谢地,我确实保存了旧版本的文件,所以我可以使用它。我将保持这个问题的开放性,以便我可以找出这个问题发生了什么。
标签: c# user-interface button unity3d unity5