Runtime SetVoxelAtArrayPosition recommended workarounds for requiring voxels to already be there?

abunner posted this 14 February 2016

After some experimenting (and finding this Trello TODO... it seems I need some workaround to start with an empty volume and then fill it myself at runtime.

Is the recommended workaround to start with a filled volume, clear it out before the first frame (set everything to inactive?) and then fill it in with the voxels I want?

Order By: Standard | Newest | Votes
GarethIW posted this 14 February 2016

The absolute best way to do this would be to create your own prefab of a volume that is the size you want, with no voxels filled in. That way all you have to do is instantiate it and start filling it with your voxels.

If all you want to do is clear an existing volume, the quickest way is to create a new voxel array:

volume.GetCurrentFrame().Voxels = new Voxel[volume.XSize * volume.YSize * volume.ZSize];

Also, the thread below this one covers resizing an instantiated volume if that is of any use as well.

Our 127 members have posted 466 times in 112 discussions