问题
I want to retrieve the text from a UI InputField but I'm not sure how.
回答1:
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);
来源:https://stackoverflow.com/questions/28292841/how-to-get-text-from-ui-inputfield