—————–
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;//使用 该引用,才能获得 Text 组件。
public class test : MonoBehaviour {
public GameObject text;
public GameObject inputtext;
// Use this for initialization
void Start () {
text.GetComponent<Text>().text = “Text”;
inputtext.GetComponent<InputField>().text = “InputText”;
}
}
—————–
新建一个 UI Input Field
新建一个文本
Input Field 组件下面有个,On Value Changed。把新建的 文本 文件对象 拖入最下方的 红色方框内。
选择 Text.Text 脚本
————————实验结果
————————
参考资料:
1.
uGUI练习(七) InputField
2.
3.
4.
5.
6.