I’m comparing a TextAsset substring to a set string I’ve created. Even when the two appear completely identical, it still does not work. Can anyone explain?
public bool ShowCard(string cardName)
{
int i = 0;
Debug.Log ("ITS CALLING IT");
foreach(GameObject card in cards)
{
string thisCardName = card.GetComponent<MissionCard>().GetCardName();
Debug.Log(thisCardName + " vs " + cardName);
if(thisCardName == cardName)
{
Debug.Log("ITS TRUE I LOVE SMALL PEOPLE!!!");
cards [i].gameObject.SetActive (true);
activeCards.Add (cards [i].gameObject);
RepositionCards ();
cards.Remove (cards [i]);
return true;
}
}
return false;
}
However even when it returns the seemingly same this… It never returns the Debug.Log within the if statement.
On calling it I’ve tried:
cardGetter.ShowCard("The High Ground\n");
cardGetter.ShowCard("\nThe High Ground");
cardGetter.ShowCard("\nThe High Ground\n");
If you want concrete details on exactly how the two strings differ, check their ToCharArray, and print the characters one by one. I’m assuming it’s some kind of white space error - either an extra newline or an extra space. You could print the length of the strings to see if that’s the issue too.