中單機(jī)游戲的讀檔與存檔有4方式,一種是自帶的數(shù)據(jù)持久化方案 采用鍵值對的方式, 可以存儲Int,,類型的數(shù)據(jù)。

一般復(fù)雜和大量的數(shù)據(jù)通過序列化()來保存數(shù)據(jù)

常見的3種:二進(jìn)制,XML方法,Json方法

二進(jìn)制方法:簡單,但可讀性差

XML方法:可讀性強(qiáng),但是文件龐大,冗余信息多

JSON方法:數(shù)據(jù)格式比較簡單,易于讀寫,但是不直觀,可讀性比XML差

這里介紹JSON()方法:

using LitJson;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace ArrowLegend
{
    /// 
    /// 存檔讀檔組件
    /// 
    public class SaveComponent :GameFrameworkComponent
    {
        private string key = "123456789";
        /// 
        /// 測試存檔
        /// 
        /// 
        private SaveData CreateSaveData()
        {
            SaveData