TextMeshPro - InputField bug

This is not a question. Just sharing an experience and hope it saves some headaches for others.

Problem: When you assign a function to the “On Value Change” event for TextMeshPro-InputField, it gets called before anything else (yes before Start(), Awake(), etc).

It means if you have any important initialization, say, in your Start() method,
and your “On Value Change” function depend on those initialization, you will get errors.

Workaround: For me assigning the function to “On End Edit” event did the trick.

195563-screenshot-from-2022-04-26-08-20-56.png

Maybe OnValueChanged is fired during the TextMeshPro.Awake(); which happens before your script’s Awake(); ?

If that’s the case you can manually set the sorting order for your script to run before the default time which will ensure your Awake(); runs before TextMeshPro.Awake(); Quick Tip: Script Execution Order - Code Monkey