Unity3d 玩家参考的奇怪的统一怪癖?

Unity3d 玩家参考的奇怪的统一怪癖?,unity3d,unityscript,Unity3d,Unityscript,所以我有一个我认为是小故障或是一个我不理解的统一的怪癖。我有以下脚本: highscore = PlayerPrefs.GetInt("Player score"); Debug.Log("high" + highscore); GUI.Box(Rect((Screen.width/2 - 150), (Screen.height/2 - 25),300,55),"Welcome to the target range!" + "\nHigh Score: " + PlayerPrefs.G

所以我有一个我认为是小故障或是一个我不理解的统一的怪癖。我有以下脚本:

highscore = PlayerPrefs.GetInt("Player score");

Debug.Log("high" + highscore);

GUI.Box(Rect((Screen.width/2 - 150), (Screen.height/2 - 25),300,55),"Welcome to the target range!" + "\nHigh Score: " + PlayerPrefs.GetInt("Player Score")+ "\nSelect Difficulty:");
但是,它显示:

Welcome to the target range!
High Score: 10
Select Difficulty
这将是好的,除了调试日志说highscore是一个不同的数字(确切地说是720)。有人知道这是为什么吗


(这不是一个大问题,因为用高分替换输出中的playerPref解决了这个问题,但我仍然想知道发生了什么事,实际上,您使用的是不同的键(注意
score
中的
s
):


键区分大小写,因此这两个键引用不同的值。

要添加这一点,键几乎应该始终存储为
const string
声明,以避免类似的错误。键永远不应该更改,如果更改,则应更改常量,而不是在任何地方使用常量的值。
PlayerPrefs.GetInt("Player score"); // first this
PlayerPrefs.GetInt("Player Score")  // later this