Unity InputField

Niraj Karki
Sep 9, 2023

--

Objective: Create a program that allows you to enter your age, sex, and location into the inspector. When you press the space key, it should print out the values.

First, create all the required Input fields and make them understandable with details on what you want from them. To access Input Field ⇒ Right-Click inside Canvas ⇒ UI ⇒ Input Field.

Now create a script and create three TMP_InputField variables representing age, sex and location; also create a TextMeshProUGUI variable which displays the entered value.

Now create a function that deals with displaying the entered value. Inside, we store all the input text data from three input field variables inside result variable.

Finally, Inside the Update function, check if the player presses the space key and if he/she does, then call the display result function.

And this is the result.

--

--

No responses yet