// The given data should have been produced by calling SerializeVoxelData() public static VoxelData DeserializeVoxelData(SerializedVoxelData data) { if (data == null) { Debug.LogWarning("Attempted to deserialize null binary data into VoxelData"); return null; } BinaryFormatter formatter = new BinaryFormatter(); using (MemoryStream stream = new MemoryStream(data.bytes)) { return new VoxelData((Voxel[]) formatter.Deserialize(stream)); } }
// The given data should have been produced by calling SerializeVoxelData() public static VoxelData DeserializeVoxelData(SerializedVoxelData data) { if (data == null) { Debug.LogWarning("Attempted to deserialize null binary data into VoxelData"); return(null); } BinaryFormatter formatter = new BinaryFormatter(); using (MemoryStream stream = new MemoryStream(data.bytes)) { return(new VoxelData((Voxel[])formatter.Deserialize(stream))); } }