Question by
iFutureStudio · Apr 03, 2019 at 05:24 PM ·
inputinputfieldintparse
I cant Multiply integer from Input Field
Hello,
I have this script that gets an amount of gold and shows you how much money its worth if you convert it.
When the input field has a value it will store it as a string and the value of gold is 1000/gold bar. Then it should take the user input and multiple the 1000. However int.Parse() is not working... :/
if(inputText.text != null)
{
string amountOfGold = inputText.text;
int goldValue = 1000;
int total = goldValue * int.Parse(amountOfGold);
money.text = total.ToString();
gold.text = amountOfGold;
money.text = "$" + total;
}
Comment
Answer by JiveViking · Sep 28, 2020 at 10:18 AM
Are you getting an error? My solution to this was checking if the input text is not equal to empty quotes. Checking if it is null wont check if the input field is empty