5

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

Alex Myers
  • 6,196
  • 7
  • 23
  • 39
kdubey007
  • 310
  • 3
  • 4
  • 9

1 Answers1

19

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);
maZZZu
  • 3,585
  • 2
  • 17
  • 21