Unity&&C#,简单选择问题,输出的Console调试日志和书上不一致

代码输出结果和《c#实践入门:快捷学习c#编程和unity游戏开发 第四版》书上的不匹配
public class LearningCurve : MonoBehaviour
{

    public bool pureOfHeart = true;
    public bool hasSecretIncantation = false;
    public string rareItem = "RelicStone";
    // Start is called before the first frame update
    void Start()
    {
        OpenTreasureChamber();
    }
    public void OpenTreasureChamber()
    {
        if (pureOfHeart && rareItem == "RelicStone")
        {
            if(!hasSecretIncantation)
            {
                Debug.Log("You have the spirit,but not the knowledge.");
            }
            else
            {
                Debug.Log("The treasure is yours,worthy hero");
            }
        }
        else
        {
            Debug.Log("Come back when you have what it takes");

        }
    }

}
运行结果

Come back when you have what it takes
书上是
You have the spirit,but not the knowledge.

经过测试,发现判断rareItem == "RelicStone"的值为假,为什么会是假?

首先要理解C#中是怎么通过==来比较两个字符串是否相等
==操作是先判断两者内存地址是否相同,相同则返回true,不同,则继续判断值是否相同。
所以你这里rareItem == "RelicStone"为什么是false,请仔细检查Inspector面板,是否在Editor中对变量进行了修改