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.
检查一下unity的inspector面板的值,是否与代码的值相同。
看起来应该是你外部修改了这个rareItem变量了吧,断点或者打印一下看看运行的时候值是多少,基本就可以定位到是在哪里设置的了
我补充一下楼上,也可能是OpenTreasureChamber函数中你修改了pureOfHeart 变量的值。