标签: c# .net if-statement unity3d
我遇到一个简单的IF语句问题:
string a = GameObject.Find("Text").GetComponent<TextMeshProUGUI>().text; Debug.Log(a); if (a == "test") GameObject.Find("PracticeButton").GetComponent<Button>().enabled = true;
表达式评估为false,即使您可以清楚地看到值是相同的。
有谁知道为什么会这样? 我尝试过String.Equals,但结果相同。