本文介绍了如何从 UI.InputField 获取文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 UI InputField 检索文本,但我不确定如何.

I want to retrieve the text from a UI InputField but I'm not sure how.

推荐答案

您可以先以某种方式获取对 gameObject 的引用,然后从中获取 InputField 组件并获取该组件的 文本变量:

You can do it by first getting reference to the gameObject somehow then getting the InputField component from it and taking the component's text variable:

    GameObject inputFieldGo = GameObject.Find("PathToTheGameObject");
    InputField inputFieldCo = inputFieldGo.GetComponent<InputField>();
    Debug.Log(inputFieldCo.text);

这篇关于如何从 UI.InputField 获取文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 20:08