【发布时间】:2020-06-17 10:17:25
【问题描述】:
我在统一使用 PlayerPrefs 时遇到错误 (C#) 在安卓上
好像没救了
脚本 1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Scores : MonoBehaviour
{
public static int highscore;
public static int points;
public void Start()
{
}
public void Update()
{
highscore = PlayerPrefs.GetInt("highscore");
PlayerPrefs.SetInt("highscore", highscore);
PlayerPrefs.Save();
}
}
脚本 2(使用它的部分)
void Update()
{
highscore = PlayerPrefs.GetInt("Highscore");
if (points > highscore)
{
highscore = points;
highscoretext.text = "Highscore: " + highscore;
highscoretext2.text = "Highscore: " + highscore;
}
当我得到一个高分例如 12 并且我死了我回到主屏幕然后回到游戏并且重新启动应用程序时高分是相同的游戏时,我可以弄清楚
【问题讨论】: