c# - 从动态输入框输入
问题描述
我正在尝试将文本添加到 Unity 中的动态输入框。我正在使用 Text Mesh Pro 资产。输入框在我想要的位置创建,但文本不显示。
代码如下:
public GameObject inputs;
public GameObject beginplek;
// Start is called before the first frame update
public void Start()
{
GameObject newinput = Instantiate(inputs, beginplek.transform.localPosition, beginplek.transform.localRotation) as GameObject;
newinput.transform.SetParent(GameObject.FindGameObjectWithTag("aaaa").transform, false);
newinput.name = "periode12";
GameObject.Find("periode12").GetComponent<TextMeshProUGUI>().text = "Hello World";
}
解决方案
您可以使用 SetText(string text) 方法
GameObject.Find("periode12").GetComponent<TextMeshProUGUI>().SetText("Hello World");
推荐阅读
- c# - HttpClient顺序调用连接错误
- python - 有没有办法在 python 中编写安全的视频?
- android - 如果启用了 FakeGPS 应用程序,则无法将位置设置设为可用
- c++ - 为什么在 C++ 中,Visual Studio 将我的类构造函数描述为具有“2+ 重载”?
- android - Flutter Firebase:如何从 Firebase Auth 调用显示名称和 UID,然后使用这些值并保存在 Cloud Firestore
- reactjs - 扩展运算符...复制状态
- c# - 发布带有时间戳的文件的构建事件
- reactjs - react-router-dom更改路由,但在用户单击页面之前不会呈现
- ios - 是否可以仅在 iOS 图表中有数据时显示 xAxis 标签
- python - vs代码显示此错误,已在系统中安装了django 2.1,但仍然显示此错误,任何人都可以建议如何解决