I have been unsuccessful trying to clear text from an input field. I can see from print statements that the text was removed but it is still displaying. In addition to this, I tried creating an InputField property as I had seen that mentioned in other posts, but was unable to place my Input Field object from the editor. Here is my script. Any help is appreciated. Thanks.
public class InputWord : MonoBehaviour {
public TMP_Text inputField;
private TextMeshProUGUI text;
private UpdateBoard updateBoard;
[SerializeField] private string word { get; set; }
private void Awake() {
text = GetComponentInChildren<TextMeshProUGUI>();
updateBoard = GetComponentInParent<UpdateBoard>();
print("InputWord.Awake inputField " + inputField + " text " + text + "\n");
}
public void Clear() {
print("InputWord.Clear 1 text.text {" + text.text + "} inputField.text{" + inputField.text + "} word{" + word +
"}\n");
word = "";
text.text = "";
inputField.text = "";
inputField.SetText("");
print("InputWord.Clear 2 text.text {" + text.text + "} inputField.text{" + inputField.text + "} word{" + word +
"}\n");
}
This is from the console:
InputWord.Clear 1 text.text {} inputField.text{jog} word{jog}
InputWord.Clear 2 text.text {} inputField.text{} word{}