- Home /
Unable to change value of Input Field text component
Learning about UniRx and ran into a seemingly small problem that I can't seem to get my head around...
public Text testText;
public InputField A;
public InputField B;
private void Start() {
Text BText = B.textComponent;
Text AText = A.textComponent;
AText.ObserveEveryValueChanged(t => t.text)
.Select(t => int.Parse(t))
.Select(i => i+1)
.SubscribeToText(BText);
}
B's text component value won't ever change. If in place of BText I subscribe to testText, which is a separate Text object, its value will update accordingly.
How could I subscribe to the string value of the Text component rather than the Text itself?
Answer by hexagonius · Dec 01, 2018 at 11:49 AM
I'd say that's because the InputField is responsible for the text, not the Text component itself:
https://docs.unity3d.com/ScriptReference/UI.InputField-text.html
Reading from it is fine (AText), but writing to it would require you to write to TextB.text, not it's text component.
I considered that as well, but I'm completely new to UniRx and couldn't quite get the method working when subscribing to the string of the Text rather than the Text object itself.
Your answer
Follow this Question
Related Questions
Clear fields after submit 3 Answers
How to convert text field to input field and back again? 0 Answers
[SOLVED] InputField inputted text will not show up when it is called to show up in a text object? 1 Answer
I have a C# script with InputField and I want to get text from this input field to another script 0 Answers
Multiple Cars not working 1 Answer