Voxel Properties

advanced scripting

Voxel Play 3 · Scripting / API

Class: All members on this page belong to VoxelPlayEnvironment. Access via VoxelPlayEnvironment.instance.

Color

void VoxelSetColor(VoxelChunk chunk, int voxelIndex, Color32 color)

Sets the tint color of a voxel. This color is multiplied with the voxel's base texture.

Visibility / Hidden State

void VoxelSetHidden(VoxelChunk chunk, int voxelIndex, bool hidden, HideStyle hiddenStyle = HideStyle.DefinedByVoxelDefinition)

Hides or shows a voxel. Hidden voxels still exist in data but are not rendered.

hiddenStyle
Controls how the hidden voxel behaves (fully invisible, semi-transparent, or as defined by the voxel type).
void VoxelSetHidden(List<VoxelIndex> indices, bool hidden, HideStyle hiddenStyle = HideStyle.DefinedByVoxelDefinition)

Hides or shows multiple voxels at once.

void VoxelSetHidden(VoxelIndex[] indices, int count, bool hidden, HideStyle hideStyle = HideStyle.DefinedByVoxelDefinition)

Hides or shows voxels from an array with explicit count.

bool VoxelIsHidden(VoxelChunk chunk, int voxelIndex)

Returns true if the voxel is currently hidden.

Custom Properties

Voxels can store arbitrary key-value pairs (float or string). Use property names or integer IDs for faster lookups.

void VoxelSetProperty(VoxelChunk chunk, int voxelIndex, string propertyName, float value)

Sets a float property on a voxel by name.

void VoxelSetProperty(VoxelChunk chunk, int voxelIndex, int propertyId, float value)

Sets a float property on a voxel by integer ID (faster than string lookup).

void VoxelSetProperty(VoxelChunk chunk, int voxelIndex, string propertyName, string value)

Sets a string property on a voxel.

void VoxelSetProperty(VoxelChunk chunk, int voxelIndex, int propertyId, string value)

Sets a string property by integer ID.

float GetVoxelPropertyFloat(VoxelChunk chunk, int voxelIndex, string propertyName)

Gets a float property value. Returns 0 if the property doesn't exist.

float GetVoxelPropertyFloat(VoxelChunk chunk, int voxelIndex, int propertyId)

Gets a float property by ID.

string GetVoxelPropertyString(VoxelChunk chunk, int voxelIndex, string propertyName)

Gets a string property value. Returns null if not set.

string GetVoxelPropertyString(VoxelChunk chunk, int voxelIndex, int propertyId)

Gets a string property by ID.

void VoxelClearProperty(VoxelChunk chunk, int voxelIndex, string propertyName)

Removes a specific property from the voxel.

void VoxelClearProperty(VoxelChunk chunk, int voxelIndex, int propertyId)

Removes a property by ID.

void VoxelClearProperties(VoxelChunk chunk, int voxelIndex)

Removes all custom properties from the voxel.

Rotation

void VoxelRotate(Vector3d position, float angleX, float angleY, float angleZ)

Adds rotation to the voxel at the given position (cumulative).

void VoxelRotate(VoxelChunk chunk, int voxelIndex, float angleX, float angleY, float angleZ)

Adds rotation to a voxel by chunk reference.

void VoxelSetRotation(VoxelChunk chunk, int voxelIndex, float angleX, float angleY, float angleZ)

Sets the absolute rotation of a voxel (replaces current rotation).

void VoxelSetRotation(VoxelChunk chunk, int voxelIndex, Quaternion rotation)

Sets the voxel rotation using a quaternion.

void VoxelSetRotation(Vector3d position, float angleX, float angleY, float angleZ)

Sets rotation by world position.

void VoxelSetRotation(Vector3d position, Quaternion rotation)

Sets rotation by world position using a quaternion.

Texture Rotation

bool VoxelSetTexturesRotation(Vector3d position, int rotation)

Sets the texture rotation index for the voxel at the given position.

bool VoxelSetTexturesRotation(VoxelChunk chunk, int voxelIndex, int rotation)

Sets texture rotation by chunk reference.

bool VoxelRotateTextures(Vector3d position, int rotation)

Rotates textures by the given amount (cumulative).

bool VoxelRotateTextures(VoxelChunk chunk, int voxelIndex, int rotation)

Rotates textures by chunk reference.

int GetVoxelTexturesRotation(VoxelChunk chunk, int voxelIndex)

Returns the current texture rotation index.

int GetVoxelTexturesRotation(Vector3d position)

Returns the texture rotation at the given world position.

Highlighting

bool VoxelHighlight(VoxelHitInfo hitInfo, Color color, float edgeWidth = 0f)

Highlights the voxel at the hit location with the specified color and edge width. Returns true if successful.

void VoxelHighlight(bool visible)

Shows or hides the current voxel highlight.

GameObjects

GameObject GetVoxelGameObject(Vector3d position)

Returns the GameObject attached to the voxel at the given position. Returns null if no GameObject is attached.

GameObject GetVoxelGameObject(VoxelChunk chunk, int voxelIndex)

Returns the attached GameObject by chunk reference.

Placeholders

VoxelPlaceholder GetVoxelPlaceholder(VoxelChunk chunk, int voxelIndex, bool createIfNotExists = true)

Gets or creates a VoxelPlaceholder MonoBehavior for the voxel. Placeholders allow per-voxel scripting and custom behavior.

void VoxelPlaceholderDestroy(VoxelChunk chunk, int voxelIndex)

Destroys the placeholder associated with the voxel.

Dynamic Voxels (Physics)

bool VoxelIsDynamic(VoxelChunk chunk, int voxelIndex)

Returns true if the voxel has been converted to a dynamic (physics-enabled) object.

bool VoxelCancelDynamic(VoxelChunk chunk, int voxelIndex)

Reverts a dynamic voxel back to a static grid voxel.

bool VoxelCancelDynamic(VoxelPlaceholder placeholder)

Reverts a dynamic voxel using its placeholder reference.

void VoxelGetDynamic(List<VoxelIndex> voxelIndices, bool addRigidbody = false, float duration = 0)

Converts multiple voxels into dynamic objects with optional physics.

addRigidbody
Add a Rigidbody for gravity and collision.
duration
Time in seconds before the voxel reverts to static. 0 = permanent.
GameObject VoxelGetDynamic(Vector3d position, bool addRigidbody = false, float duration = 0)

Converts the voxel at the given position to a dynamic object. Returns the created GameObject.

GameObject VoxelGetDynamic(VoxelChunk chunk, int voxelIndex, bool addRigidbody = false, float duration = 0)

Converts a voxel to a dynamic object by chunk reference.

Throw & Create

GameObject VoxelThrow(Vector3d position, Vector3 direction, float velocity, VoxelDefinition voxelType, Color32 color)

Throws a voxel as a physics projectile from the given position in the specified direction.

GameObject VoxelCreateGameObject(Color32[] colors, int sizeX, int sizeY, int sizeZ)

Creates a standalone voxel-styled GameObject from a color array. Not part of the voxel world grid.

GameObject VoxelCreateGameObject(Color32[] colors, int sizeX, int sizeY, int sizeZ, Vector3 offset, Vector3 scale)

Creates a voxel-styled GameObject with custom offset and scale.

Was this page helpful?