Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

How do I set the text of the new Input Field's Built In Text UI Object in Unity 5+?

 myInputFieldText.text = "Text Value I Want";

The code above does not work to set the text inside of a InputField's Text. Thanks

share|improve this question
    
is the component enabled? where is that code located? –  Leggy7 Mar 20 at 15:59

1 Answer 1

Turns out that the Text component of a InputField can be used to easily read the text, but setting the value of the text requires more than just changing the InputField's Text.text. The fastest way to set an InputField's Text's text is actually to go right to the InputField itself and to set it's Text that will automatically update the InputField's text component.

So:

myInputField.text = "Text Value I Want";

Will also set myInputFieldText.text to the same value

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.