Tthe following code adds a new voxel definition at runtime (playmode).
First, it creates a new instance of VoxelDefinition and populates basic fields like name "Brick", the render type (in this case full opaque voxel) and the textures to be used.
Then, it places a new voxel of the new type just over the crosshair (this part is optional and provided to complete the example).
VoxelDefinition vd = env.GetVoxelDefinition ("Brick"); if (vd == null) { vd = ScriptableObject.CreateInstance<VoxelDefinition> (); vd.name = "Brick"; vd.renderType = RenderType.Opaque; vd.textureTop = texture; vd.textureSide = texture; vd.textureBottom = texture; env.AddVoxelDefinition (vd); } VoxelPlayFirstPersonController fpsController = VoxelPlayFirstPersonController.instance; if (fpsController.crosshairOnBlock) { Vector3 pos = fpsController.crosshairHitInfo.voxelCenter + fpsController.crosshairHitInfo.normal; env.VoxelPlace (pos, vd); }
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article