Hi, I am wondering what the class name for the new Text script is, as I want to write a script that changes it’s text.
Edit: Add “using UnityEngine.UI”
Hi, I am wondering what the class name for the new Text script is, as I want to write a script that changes it’s text.
Edit: Add “using UnityEngine.UI”
The class name is ‘Text’
For C#, do something like this (for JS, chariot’s comment has some sample-code):
using UnityEngine;
using UnityEngine.UI;
// attach the Text-object from your scene to this using the inspector
public Text myGuiText;
void Update(){
myGuiText.text = "I love text. I love it good!";
}
or get the component from script:
using UnityEngine;
using UnityEngine.UI;
private Text myGuiText;
void Start(){
myGuiText = GetComponent<Text>();
}
void Update(){
myGuiText.text = "I love text. I love it good!";
}