I have a problem with calling onValueChanged on an InputField. It seems that currentText is updated before entering if case. Maybe I’m not seeing something. Any idea?
-
Example
-
First Step:
-
Inputfield: abcd
-
currentText: abcd
-
Second Step:
-
Remove “d”
-
currentText: abc
-
oldText: abc
// Script 1 public override void SetText(InputField _currentText) { if (currentText != null /*&& currentText != oldText*/) { Debug.Log("Current text: " + currentText.text); oldText = currentText; Debug.Log("Old text: " + oldText.text); } currentText = _currentText; Debug.Log("Current text: " + currentText.text); } // Script 2 private void Start() { editedText = new TextReceiver(); textField.onValueChanged.AddListener(delegate { editedText.SetText(textField); }); }