Hello I would like to use a variable, Country, and check it in a if statement, and if that equals “USA” then to proceed with the if statement, however I always get a error from unity.
Seems other people have asked this too (here or here ). Anyways, see below for two options:
private String myCountry = "This is a string with the word USA";
// NON-EXACT MATCH
if (myCountry.Contains("USA")) {
Debug.Log("USA in string...")
} else {
Debug.Log("USA not in string...");
}
// EXACT MATCH
if (String.Equals(myCountry, "USA")) {
//stuff to do when true
Debug.Log("STRING MATCHES USA");
} else {
//stuff to do when false
Debug.Log("STRING DOES NOT MATCH USA");
}