遇到C#脚本问题

时间:2014-03-14 05:28:42

标签: c# unity3d

当我保存我的脚本时,它会出现这些错误:

  

Assets / Player Controller.cs(38,128):错误CS1526:新表达式在类型后需要()或[]。

和这个

  

Assets / Player Controller.cs(38,129):错误CS8032:解析期间内部编译器错误,使用-v运行以获取详细信息。

我研究了它,但没有答案。有人可以帮忙吗?问题出在这一行:

GUI.TextField (new Rect (Screen.width / 2 - 65, Screen.height / 2 - 11, 130, 22) "Do something to start"); }

1 个答案:

答案 0 :(得分:4)

您在GUI.TextField(Rect, string) constructorRectstring参数之间缺少逗号。

请改为尝试:

GUI.TextField (new Rect (Screen.width / 2 - 65, Screen.height / 2 - 11, 130, 22), "Do something to start"); }

另外,考虑跨多行格式化以使结构更清晰(这样的错误更容易发现):

    GUI.TextField(
        new Rect(Screen.width / 2 - 65, Screen.height / 2 - 11, 130, 22),
        "Do something to start");
}