Getting the InputField text

I have a very simple question. I have 5 inputfield (new UI System) on my screen and I’d like to receive the text of one of them after clicking on a button. What should I do? I used to use FindGameObjectWithTag but it looks that this UI system doesn’t consider these components as gameobjects. Pay attention that there is more than 1 inputfield on screen.

  UnityEngine.UI.InputField userInputField = GameObject.FindGameObjectWithTag("usernameinput") as UnityEngine.UI.InputField;

This should work:

Add “using UnityEngine.UI;” at the top with the rest

GameObject userInputField;

void Start()
{
    userInputField = GameObject.FindGameObjectWithTag("usernameinput");
}

and then to get the text just use

userInputField.GetComponent<InputField>().text