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  = historyScore.ToString();
        textNowScore.GetComponent().text = score.ToString();
    }

}

 

你可能感兴趣的:(Unity3D引擎)