using System.Collections.Generic; using UnityEngine; public class AxiPlayerPrefsForFileSystem : AxiPlayerPrefsFileBase { public AxiPlayerPrefsForFileSystem() : base(LoadData, SaveData) { Debug.Log($"AxiPlayerPrefsForPSVita Init"); } protected static Dictionary LoadData() { if (!AxiIO.AxiIO.io.file_Exists(AxiPlayerPrefsFilePath)) return new Dictionary(); else { string outputData = string.Empty; byte[] loadedData = AxiIO.AxiIO.io.file_ReadAllBytes(AxiPlayerPrefsFilePath); if (loadedData != null && loadedData.Length != 0) { using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData)) { using (System.IO.BinaryReader reader = new System.IO.BinaryReader(stream)) { outputData = reader.ReadString(); } } } if (string.IsNullOrEmpty(outputData)) return new Dictionary(); return AxiPlayerPrefsFileBase.JsonStrToData(outputData); } } protected static void SaveData(Dictionary data) { string jsonStr = AxiPlayerPrefsFileBase.DataToJsonStr(data); byte[] dataByteArray; using (System.IO.MemoryStream stream = new System.IO.MemoryStream(jsonStr.Length * sizeof(char))) { System.IO.BinaryWriter binaryWriter = new System.IO.BinaryWriter(stream); binaryWriter.Write(jsonStr); dataByteArray = stream.GetBuffer(); stream.Close(); } AxiIO.AxiIO.io.file_WriteAllBytes(AxiPlayerPrefsFilePath, dataByteArray, false); } }