Voxel Array

A container for voxels. It has to be disposed manually.

Properties

The size of the array in one axis (max. 32).

public int Size { get; }

The number of voxels in the array (size^3).

public int Length { get; }

Methods

Creates a new VoxelArray with the specified size for one axis.

public VoxelArray(int size, Allocator allocator = Allocator.Persistent, NativeArrayOptions nativeArrayOptions = NativeArrayOptions.ClearMemory)

Returns the internal NativeArray.

public NativeArray<Voxel> AsArray()

Releases the memory of the VoxelArray.

public void Dispose()

Indexers

public Voxel this[int x, int y, int z]
public Voxel this[int3 position]

Example

public class VoxelArrayExample : MonoBehaviour
{
    VoxelArray voxels;

    void Start()
    {
        voxels = new VoxelArray(32);
        voxels[0, 0, 0] = new Voxel(1);
    }

    void OnDestroy()
    {
        voxels.Dispose();
    }
}

Last updated