unity 4.6中使用canvas获取text并改变text显示内容



 public void AddScore(int scoreValue)
    {
        GameObject.Find("Canvas").GetComponent<Text>().text="Score:"+scoreValue;

    }

倒入了unityEngine.UI。这是按照以前GuiText的思路写的,但是无法成功,应该怎么写呢

unity3d c# JavaScript

其实我是你爸 9 years, 7 months ago

GameObject.Find("Canvas/Text").GetComponent(UI.Text).text="Score:"+scoreValue;
这样就可以了

薔薇殺しD鸑鷟 answered 9 years, 7 months ago

Your Answer