I’ve added the three voxel block types as children of each of the Cubes. The BlockTypeEditor script has also been added to each of the cubes. It runs in the Editor. The dropdown Waypoint Type allows the designer to select which of the three block types should be displayed within a Cube. For now, these three child objects need to be Serialized since the Start method does not run in the Editor.
Drag the three Block prefabs from the Voxel asset under your Cube prefab and then save the prefab. Create three empty scripts called EnemyBlock, FriendlyBlock, and NeutralBlock and drop them onto the appropriate prefabs. Then, drag each of those prefabs into the appropriate slot of the BlockTypeEditor.
And the code for the BlockTypeEditor:
And the base prefabs are set up to use the CubeEditor and Waypoint scripts.
The Enemy_Base prefab needs to be adjusted so that the spawning platform can act as a Waypoint space. I adjusted the Friendly_Base the same amount.
As a final note on the level setup, I added a Waypoint Name field so that everything isn’t called “Cube (X,X)” anymore.
And here’s how I update the name field in the UpdateLabel method: