hi everyone ,i want to ask a question about how to change the text my Text UI element will display by scripting,i just write a simple script attched to a Text UI element:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class MyScoreText : MonoBehaviour {
public GameObject player;
private PlayerStuff playerStuff;
void Start(){
playerStuff = player.GetComponent<PlayerStuff>();
}
void Update(){
gameObject.guiText.text = playerStuff.Score.ToString ();
}
}
but i was told that there is no “GUIText” attached to my gameobject(Text UI element).
At firsti think i should use like “gameObject.text = playerStuff.Score.ToString ()”,but text doesn appear as one of the variables of gameObject.
coule anyone tell me how to change the text by scripting ?
My Text UI element was created by “GameObject->UI ->Text”