public void AddScore(int scoreValue)
{
GameObject.Find("Canvas").GetComponent<Text>().text="Score:"+scoreValue;
}
倒入了unityEngine.UI。这是按照以前GuiText的思路写的,但是无法成功,应该怎么写呢
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
GameObject.Find("Canvas/Text").GetComponent(UI.Text).text="Score:"+scoreValue;
这样就可以了
因为组件不是 Text 了,具体楼上已经说了