I'm currently working on taking an idea I've been toying with in C++ and bringing it into Unity, but I'm struggling to figure out how to make it performant and how to do things the "Unity way".
My world is made up of cubes and cube shaped tiles viewed from a fixed angle (à la Monument Valley). I've watched their behind the scenes video and seen that they have a step in their workflow that removes the unused faces from their cubes and combines them into quads. I want to achieve something similar.
Ideally I want to build up my world using a bunch of prefab cube objects (with different textures and components) and then run some kind of process over my scenes before I export/play to optimize them (otherwise I'm going to be doing potentially thousands of draw calls that I don't need to do and have lots of colliders I don't need).
My questions are as follows:
- What hooks does Unity provide to do this sort of processing? Should I be using PostProcessSceneAttribute for this?
- I understand that I can use Mesh.CombineMeshes to combine my cubes, but what about for their colliders?
- How can I determine groups of cubes that are touching (for removing faces and combining colliders)? In my C++ project I keep all of the blocks in a 3D array and use that, but using the Unity editor to place the blocks means I don't have this available. Is there a way I could easily build one from my scene, or is there a more "Unity" way of doing this?
- Is my approach sensible? Or should I drop the idea of placing individual cubes in the editor and take a different approach?