This is a weird error. I have a TextMeshPro input field that has a content type of Integer to ensure only integers are entered. When I do int.Parse() it throws the “not in a correct format” error, even though it’s an integer.
I enter something like 123 into the text field and it throws the error. If I test the int.Parse(“123”) it works fine, but if I use the text from the input field it doesn’t.
Does anyone know what’s up?
Example of the code:
string inputText = tmProInput.text.ToString(); // Enter 123 as the input, only integers are allowed
Debug.Log("Input text: *" + inputText + "*");
int inputInt = int.Parse(inputText); // This Fails
int inputInt = int.Parse("123"); // This Works
Yup the end of line is. I looped through and it has some odd character that doesn’t print, even though it’s set to “Single Line”. I just Substring the text to the length minus 1 and it worked. I had another input field it was doing the same thing to.