I’m not sure If I’m doing this correct so I want to know if anybody else has found this bug yet.
I’m using Unity 5.5.0p3
Programmatically I wanted to change the text of an InputField for testing, There are two different ways to do this, I’m sure in version 5.4.1 which I was using previously this worked fine.
You can use the InputField’s Text method or find the text component which is in the InputField and use that text field.
I’ve found that the latter does not work programmatically or even when your running and manually change it in the inspector can somebody clarify this please before I send a bug report.
Your inputfield has a text portion. You change this value. You do not change the text child that comes with it.
so myInputfield.text would be basically what you change. Input fields come with a child text component, but you don’t change that with code.
Like I said I’m sure I was able to do this in 5.4.1, as I upgraded it in mid prototyping, it does seem strange no been able to change the text programmatically using that component, as I can change the text colour fine, and that’s the only way to change the text colour that way.
I don’t recall ever changing the text child. I think it’s because doing so makes the inputfield overwrite it anyways, so it really does nothing. I have personally never changed that text except through the inputfield. Otherwise, there doesn’t seem to be a reason to use the inputfield. I think even unity mentions in their docs somewhere that you should use the inputfield text.
You can change other parts of it through the textbox because that handles the displaying of it. Stuff like font size and such are controlled through the textbox itself.