While we often just wish to display non-interactive text messages to the user, there are times (such as name entry for high scores) where we want the user to be able to enter text or numbers into our game. Unity provides the UI Input Field component for this purpose. In this recipe, we'll create an Input Field that prompts the user to enter their name:
Having interactive text on the screen isn't of much use unless we can retrieve the text that's entered to be used in our game logic, and we may need to know each time the user changes the text's content and act accordingly. In this recipe, we'll add an event handler C# script that detects each time the user finished editing the text and updates an extra message onscreen, confirming the newly entered content.