大家好,我正在写一个脚本,它工作得很好,但只有一个错误,我就是找不出来。我忽略了什么?我将在下面发布错误和代码。
下面是错误:
UnassignedReferenceException: The variable gameOverScore of Score has not been assigned.
You probably need to assign the gameOverScore variable of the Score script in the inspector.
Score.Start () (at Assets/2dspaceshooter/Scripts/Score.js:10)下面是脚本:
#pragma strict
var gameOverScore:GUIText;
var gameGUI:GameObject;
private var score:int = 0;
private var isGameOver = false;
function Start () {
gameOverScore.guiText.enabled = false;
guiText.text = "Score: " + score.ToString();
}
function addScore () {
if(!isGameOver){
score += 10;
guiText.text = "Score: " + score.ToString();
}
}
function doGameOver () {
isGameOver = true;
gameGUI.SetActive(false);
guiText.text = null;
gameOverScore.guiText.enabled = true;
gameOverScore.guiText.text = "Score: "+score;
}发布于 2014-12-29 21:54:28
我并不是真的认为您的脚本是简单的JavaScript,而是您可能将对象Score与小写版本score混淆了
https://stackoverflow.com/questions/27690151
复制相似问题