Most efficient way to create cubes with multiple textures

Hi all,

I'm trying to make a level manager that can build levels using different types of cube prefabs. I've got the basics working, but the problem I've come up against is when I have a cube that requires multiple textures.

I wasn't able to get multiple textures to work in Unity, so I dropped into Cinema4D and made the cube in there, then brought it back into Unity. When I look at the imported object in Unity I see that for each cube I have 6 separate planes and meshes which seems inefficient to me considering the amount of cubes that will be made.

Does anyone have any idea how I could streamline this a little nicer? I want to be able to create hundreds of different types of cubes.

Thank you in advance for any help that's offered.

Yep that's to be expected.

In terms of making it more efficient you want to look into combining cube faces that share the same material. How you achieve that depends on your project and requirements.

I would start by just building the planes for all the cubes in a level, then sort them by material type and finally use those to build new meshes, one for each type of material containing all of the faces that use that material.

If you levels are very large I might break down the 'one mesh per material' into several based on spatial volume, so that gross level culling can take place.

This should of course be done once at the start of the level. If you need it working in an 'editor' type mode, then just use a single special cube, that uses 6 materials so the designer can see what they are placing and once placed, rebuild the meshes that need it.

That's about as streamlined as it's going to get. I suppose the "proper" way to do it is to use submeshes, so the cube will have 6 materials, with each material applying to a separate submesh. However, in practical rendering terms the results are basically the same either way.