/// <summary> /// 反序列化 /// </summary> /// <param name="bytes"></param> public void Deserialize(byte[] bytes) { if (bytes == null) { return; } BinaryFile file = new BinaryFile(System.Text.Encoding.Unicode); if (!file.OpenRead(bytes)) { file.Close(); return; } BinaryReader reader = file.m_Reader; this.Uid = reader.ReadUInt32(); this.SceneAddressableKey = reader.ReadString(); int areaInfosLength = reader.ReadInt32(); if (areaInfosLength > 0) { this.AreaInfos = new AreaInfo[areaInfosLength]; for (int iArea = 0; iArea < areaInfosLength; iArea++) { AreaInfo areaInfo = new AreaInfo(); areaInfo.Deserialize(reader); this.AreaInfos[iArea] = areaInfo; } } this.VoxelGridInfo = new VoxelGridInfo(); this.VoxelGridInfo.Deserialize(reader); file.Close(); }
private void WriteMapInfoBinary(BinaryFile file) { BinaryWriter writer = file.m_Writer; writer.Write(this.Uid); writer.Write(this.SceneAddressableKey); if (this.AreaInfos == null || this.AreaInfos.Length <= 0) { writer.Write(0); } else { writer.Write(this.AreaInfos.Length); for (int iArea = 0; iArea < this.AreaInfos.Length; iArea++) { AreaInfo areaInfo = this.AreaInfos[iArea]; areaInfo.Serialize(writer); } } VoxelGridInfo voxelGridInfo = this.VoxelGridInfo; voxelGridInfo.Serialize(writer); }