public override byte[] Save() { using (CustomStream ms = new CustomStream()) { ms.WriteInt(13 + 4 + name.Length); ms.WriteInt(id); ms.WriteString(name); ms.WriteInt(p1); ms.WriteFloat(p2); ms.WriteBoolean(p3); return(ms.ToArray()); } }
public void LoadTxtSaveToData <T>(string loadPath, string savePath) where T : BaseEntity { string s1 = LoadTextFile(loadPath);//Application.streamingAssetsPath + @"\Table01.txt" List <T> dataList = ConvertString2EntityList <T>(s1); using (CustomStream cs = new CustomStream()) { cs.WriteInt(dataList.Count); for (int i = 0; i < dataList.Count; i++) { byte[] beBuffer = dataList[i].Save(); for (int j = 0; j < beBuffer.Length; j++) { cs.WriteByte(beBuffer[j]); } } byte[] buffer = cs.ToArray(); SaveToData(buffer, savePath); } }