Getting the text from UIInput

I have an area for the user to enter their name, which I then want to store for later usage. To do this I have a UIInput called ‘NameInput’ which has a label called ‘label’ that should hold the name they have entered.

I’m pretty new with Unity so I have no idea how I would go about getting the text in the label. I know that I need to use GetComponent (i think) but I’m not sure on how to use it. Does anyone have a nice example I can use for C# or if you could post the code with an explanation of how to get it that would be great.

There are several ways, the most easy on probably is using the text component of UIInput, like:

string textYouTyped = myInputField.GetComponent<UIInput>().text;

Where myInputField does reference the input widget.

Also, check the official NGUI forum where you’ll find more on this specific plugin.