分数没有在guiText中显示

时间:2014-10-01 21:52:48

标签: unity3d unityscript

我有guiTexts,名为scoreLevel1,scoreLevel2,我想从正确的级别显示分数,但它没有显示任何文本或分数......没有构建错误。如何让它按预期显示?

var Score : int;

function Update () {
    Score -= 1 * Time.deltaTime;
    guiText.text = "Score: "+Score;
    TimerOfDeath();
}

HighScores.js

//run at start if score doesn't exist yet to initialise playerPref
function Start(){
    if(!PlayerPrefs.HasKey(Application.loadedLevelName+"HighScore"))
        PlayerPrefs.SetFloat(Application.loadedLevelName+"HighScore", 0);
}

//run when level is completed
function OnTriggerEnter(other : Collider){
    if(other.tag == "Player"){
        Score = gameObject.Find("ScoreCount").GetComponent("ScoringPts").Update("Score");
        if(Score > PlayerPrefs.GetFloat(Application.loadedLevelName+"HighScore"))
        {
            PlayerPrefs.SetFloat(Application.loadedLevelName+"HighScore", Score);
        }
    }
}

GetHighScores.js

#pragma strict

function Start () {
    var hscount = 1;
    var iterations = 1;
    var maxIterations = 5;
    var findtext = gameObject.Find("scoreLevel"+(hscount));
    while(hscount < 5 && iterations < maxIterations){
        if(!PlayerPrefs.HasKey("Level"+(hscount)+"HighScore")){
            findtext.guiText.text = "Level"+(hscount)+ ": " + PlayerPrefs.GetFloat("Level"+(hscount)+"HighScore");
            hscount++;
        }
        iterations++;
    }
}

0 个答案:

没有答案