Hello,
I am currently working on the in-game console and I keep getting one error.
What I do is when I type something in the input field I check if the input field text contains space char and if so I want to change the text color by adding color tag, but everytime I try to add color tag I get this error:
Error:
StackOverflowException
TMPro.TMP_InputField.set_text (System.String value)
I am most likely missing something obvious as always… Can someone explain to me why is this happening?
Thank you!
Script:
public void OnValueChange (string _text)
{
if (_text.Length > 0)
{
char[] chars = _text.ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
if (chars[i] == ' ')
{
if (startCommand) return;
_inputField.text += "<color=#F3B028>"; //The error points to this line
_inputField.selectionAnchorPosition = _inputField.text.Length;
startCommand = true;
return;
}
}
startCommand = false;
}
}