I want to retrieve the text from a UI InputField
but I'm not sure how.
To insert a Text UI element in Unity, right-click on the Scene Hierarchy, then select GameObject -> UI -> Text. There are many properties of the Text element. In which Text Field is the most important property. You can type out what you want the text box to show in that field.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With