When placing a custom voxel, it's possible to get the gameobject created. Note that if you enable the GPU Instancing option in the voxel definition you will also need to enable the "Create GameObject" checkbox (when using GPU Instancing, Voxel Play does not create gameobjects by default; if GPU instancing is not enabled for the custom voxel, then it will always create a gameobject).
Use this code to select the gameobject created when placing a custom voxel:
// Get the gameobject in the scene placed in "placePos" position VoxelChunk theChunk; int theIndex; VoxelPlayEnvironment env = VoxelPlayEnvironment.instance; env.GetVoxelIndex (placePos, out theChunk, out theIndex); VoxelPlaceholder placeholder = env.GetVoxelPlaceholder (theChunk, theIndex); // Select it in the Editor placeholder.transform.SetParent(null); UnityEditor.Selection.activeGameObject = placeholder.gameObject;(edited)
where placePos is the location of the voxel.
The last two lines are just for showing the voxel in the inspector. When you place a custom voxel, a voxel placeholder gameobject is created in the scene but because it's parented to the chunk it's hidden in the hierarchy therefore it needs to be unparent it in order to visualize it in the hierarchy (only for illustration purposes).
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