Legacy Documentation: Version 2017.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Text.text

public string text;

Description

The string value this Text displays.

This is the string value of a Text component. Use this to read or edit the message displayed in Text.

using UnityEngine;
using UnityEngine.UI;

public class Example : MonoBehaviour { public Text m_MyText;

void Start() { //Text sets your text to say this message m_MyText.text = "This is my text"; }

void Update() { //Press the space key to change the Text message if (Input.GetKey(KeyCode.Space)) { m_MyText.text = "My text has now changed."; } } }

Did you find this page useful? Please give it a rating: