Changing the content of an Input Field using voice input.

Hello,

I’m working on a small c# project and trying to use IBM’s Watson to input my voice into a unity InputField. I’ve assigned a UI text object to the “Placeholder” and “TextComponent” slots on the InputField, and so far, I can get the voice input to change the text in the “placeholder” object, but I can’t get it to change text in the “Text Component” object.

To do this, I’m getting the result of my voice input from the Watson script, and using “GameObject.Find” to find the relevant UI text object I want to change, and then assigning the voice input result to that text object. I’ve swapped them over to check there isn’t an issue with either, and whatever is in the “TextComponent” slot won’t update.

I’m assuming that the InputField script doesn’t allow the TextComponent variable to be changed directly unless a key is pressed, or similar. Does that sound right, or is it likely to be something else?

InputField controls the value of the text component. You’ll want to set the value of text on the InputField instead.

Thanks, I’m now creating a variable “public InputField inputfield” and then setting inputField.text directly, and that seems to work.