Version: 2017.2
public string text ;

描述

此 Text 显示的字符串值。

这是 Text 组件的字符串值。使用此设置可读取或编辑 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."; } } }