【发布时间】:2016-07-21 16:22:18
【问题描述】:
以下代码从 Google Play 排行榜中检索玩家的分数。如果检索到的值优于设备上已存储的值,则保存分数。
public void Update()
{
PlayGamesPlatform.Instance.LoadScores(
"myLeaderboardID",
LeaderboardStart.PlayerCentered,
100,
LeaderboardCollection.Public,
LeaderboardTimeSpan.AllTime,
(data) =>
{
if (data.Valid)
if (data.Scores[0].value > PlayerPrefs.GetInt("highScore", highScore))
{
PlayerPrefs.SetInt("highScore", data.Scores[0].value);
PlayerPrefs.Save();
}
});
}
不幸的是,我在这一行遇到了 2 个错误PlayerPrefs.SetInt("highScore", data.Scores[0].value);
error CS1502: The best overloaded method match for `UnityEngine.PlayerPrefs.SetInt(string, int)' has some invalid arguments
error CS1503: Argument `#2' cannot convert `long' expression to type `int'
我该如何解决这个问题?
【问题讨论】:
-
您是否尝试过将 long 显式转换为 int?