// 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));
        }
    }
Exemple #2
0
    // 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)));
        }
    }