kdubey007
kdubey007

Reputation: 310

How to get Text from UI.InputField?

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

Upvotes: 5

Views: 29080

Answers (1)

maZZZu
maZZZu

Reputation: 3615

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);

Upvotes: 19

Related Questions