UGUI文本输入

UGUI文本输入

using UnityEngine;
using UnityEngine.UI;

public class TestInput : MonoBehaviour {
    private Text _text;
    private InputField _inputField;

	void Start () {
        _text = GameObject.Find("Text").GetComponent<Text>();
        _inputField = GameObject.Find("InputField").GetComponent<InputField>();
        
    }
	
	void Update () {
        _text.text = _inputField.text;
    }
}

在这里插入图片描述
直接 .text即可获得输入的字符串。

猜你喜欢

转载自blog.csdn.net/weixin_43492764/article/details/85676550
今日推荐