C# A big Cube made from Cubes atleast 40x40x40 - Lag Fix

(repost because after 17 hours my question is still not reviewed by a moderator, something probaby went wrong.)

C# A big Cube made from Cubes atleast 40x40x40 - Lag Fix

Alright I need to make a big cube. This cubus has to exist out of smaller cubusses.
like this for example: example image url

Now I do need box colliders to collide with things like my mouse/touch raycast and other things so, no box colliders is not going to work.

I also need to destroy the blocks from a great distance to a small inch.

The big cube needs to be able to rotate, it will use a empty gameobject I will place in the center.

I tried many things, still don’t have the perfect solution.

40x40x40 is 64.000 blocks.

I just want a way how to do this.

GameObjects are expensive, you need to merge the cubes into as few game objects as possible. This means using custom meshes and math to determine what was clicked instead of thousands of colliders. Lots of Minecraft questions have detailed responses on how to do cubic meshes and hit detection.

Physics.Raycast has the option to return the hit triangle in the RaycastHit info, and cubic meshes / mouse position math are reasonably straightforward.