error CS1002: ; expected錯誤原因:少打分號。
NullReferenceException: Object reference not set to an instance of an object錯誤原因:宣告了 GameObject 變數但沒有指定值。
UnassignedReferenceException: The variable xxx of NewBehaviourScript has not been assigned.錯誤原因:宣告了 public 變數但沒有到 Inspector 指定值。
若有指定值仍一直出現錯誤訊息,檢查看看該 script 是否還套用在其他物件上。(請參閱「
如何得知script套用在哪些物件?」這篇文章)
The name `xxx` does not exist in the current context錯誤原因:使用了 xxx 變數但沒有先宣告。
Unexpected symbol `}`錯誤原因:多了右花括弧(或少了左花括弧)。
Unexpected symbol `end-of-file`錯誤原因:少了右花括弧(或多了左花括弧)。
Unexpected symbol `可能原因:script 中有"全形"空格或符號。
※ 關於發佈 Android(輸出apk)出現的錯誤訊息,請參考 這篇文章。
建議延伸閱讀:
>>
unity C# 語法教學入門
>>
Unity Script 常用語法教學(unity課程入門學習筆記)