I want to put a script on my TMP input field so that when the text is changed (or maybe some other event as I don’t want the event to launch at each key stroke) an action is filled with some data (made a class for it) in order for a manager to act on that event.
How do I do that first script: listen to which component’s which event (onDataUpdated?) so that I can Action it myself with my own data (that I know how to do) so that my manager acts on it (I know that too).
Here is an example script that I use to test input field events.
Create a scene that includes a TMP Input Field and TextMeshProUGUI text object. Add this script to the TextMeshProUGUI text object and then set the public reference to the input field.
What is the difference between the TMP_inputField component in the root gameobject and the Text Mesh Pro UGUI component in the placeholder and text children gameobject?
When working with the Input Field, you only want to access the parent TMP_InputField component as the other components are there for structural reasons and to show text.
For instance, imagine you are using an input field to get a password from a user. The TMP_InputField.text would contain the password while the underlying TMP_Text.text would contain “******” which is what is displayed instead of showing the password.
The example script I provided covers the essential events from the input field.
Correct. You would set the text on the TMP_InputField itself and not on the underlying text components. The Placeholder text is an exception since it is only used to display “placeholder” text.