i want convert inputfield to int but its coming with errors
this i using script
and this is error.What was the text that you let input() parse? The error indicates that the error was in the characters. You may also want to check out int.TryParse()
I can almost guarantee the problem is that the inputfield is empty. @csofranz is right. You should pretty much always use TryParse because who knows what a user is going to type.
public InputField inputMiktar;
public int girilenMiktar;
// Start is called before the first frame update
public void input()
{
girilenMiktar = int.TryParse(inputMiktar, out girilenMiktar);
}
i write this code but its coming with error:
1 argument: Unable to convert from ‘UnityEngine.UI.InputField’ in ‘string’
You forgot to add “.text” to get the contents of the input field instead of the field itself.