How to get Text from UI.InputField?

后端 未结 1 1993
南旧
南旧 2020-12-11 19:53

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

1条回答
  •  攒了一身酷
    2020-12-11 20:10

    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();
        Debug.Log(inputFieldCo.text);
    

    0 讨论(0)
提交回复
热议问题