scoreText.text无法统一工作

时间:2017-10-16 11:16:34

标签: c# unity5

<分数:“得分:”没有显示在统一身份上。我已经尝试了很多,似乎没有任何工作,也没有按预期得到输出.Thankyou.Sorry for bad English。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class uiManager : MonoBehaviour {
public Text scoreText;
int score;

// Use this for initialization
void Start () {
    score = 0;

}
void score_view()
{
    score = move.score;
    Debug.Log("uiManager Score:"+score);
    scoreText.text = "Score:"+score;
}

// Update is called once per frame
void Update ()
{
    score_view();

}
}

1 个答案:

答案 0 :(得分:0)

如果您的GameObject处于活动状态,并且您的脚本已启用,则每帧调用一次更新 此外,你的游戏应该正在运行。

https://docs.unity3d.com/ScriptReference/MonoBehaviour.Update.html

您可以使用以下变量检查此状态:

this.gameObject.activeSelf
this.enabled
相关问题