unity中存档读档示例

using UnityEngine;
using UnityEngine.UI;

public class GameOver : MonoBehaviour {
    public  Text textBestScore;
    public  Text textNowScore;
    public void Show(int score)
    {
        int historyScore = PlayerPrefs.GetInt("historyHighScore", 0);
        if(score >historyScore)
        {
            PlayerPrefs.SetInt("historyHighScore", score);
        }
        textBestScore.GetComponent <Text >().text  = historyScore.ToString();
        textNowScore.GetComponent<Text>().text = score.ToString();
    }

}

猜你喜欢

转载自blog.csdn.net/qq_40323256/article/details/82347955
今日推荐