首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >变量赋值问题

变量赋值问题
EN

Stack Overflow用户
提问于 2014-12-29 21:49:23
回答 1查看 66关注 0票数 0

大家好,我正在写一个脚本,它工作得很好,但只有一个错误,我就是找不出来。我忽略了什么?我将在下面发布错误和代码。

下面是错误:

代码语言:javascript
复制
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)

下面是脚本:

代码语言:javascript
复制
#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;
}
EN

回答 1

Stack Overflow用户

发布于 2014-12-29 21:54:28

我并不是真的认为您的脚本是简单的JavaScript,而是您可能将对象Score与小写版本score混淆了

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27690151

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档