public string text ;

Descripción

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.

//Attach this script to a GameObject.
//Create a Text GameObject (Create>UI>Text) and attach it to the My Text field in the Inspector of your GameObject
//Press the space bar in Play Mode to see the Text change.

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 = "Text has changed."; } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961