If your GUI text is a number, you need to parse it first.
int value;
if (int.TryParse(Blah.guiText.text, out value))
{
if (value > 2000)
{
Blah blah blah;
}
}
else
{
// The number could not be parsed.
Debug.Log("Could not parse integer.");
}
You can use int.Parse to turn a string into a number, but if it fails, it will throw an exception, which will stop your game. If you use int.TryParse, you can stop that from happening. If the TryParse fails, you can warn the Player or take some action to correct the problem and then try again.
The convert function is a part of the System namespace so you’ll need to include it at the start of the c# file.
using System;
int MyBlahBlahVar = Convert.ToInt32(Blah.guiText.text);
Keep in mind that EddyEpic’s solution would be more valid if the variable being tested can possibly contain anything that isn’t a numeric related character in the string. Mine does no testing what so ever and will likely go bork if there’s any funny character stuff in the numeric string.
Yes Eddys worked right off the bat…But I appreciate you guys taking the time to explain it to me… I have done this before with .net and it did not click till after the fact.