Generated Mesh disappearing

Hello everybody.

I’m working on a game where I generate an asteroid belt procedurally, where the biggest asteroids are also procedurally generated meshes.
After the mesh generation, I calls Mesh.RecalculateBounds(), but the mesh appears and disappears when I move the camera (in game and scene view). I quickly added a piece of code to show the bounding boxes of the mesh (Mesh.bounds, and MeshRenderer.bounds) as gizmos, but it is always in the camera view, so it shouldn’t be culled.

Does anyone already have this issue ? Any solution ?

Thanks.

I found that the mesh issue was due to the combination of dynamic batching enabled and forward rendering mode.
Disabling dynamic batching of setting the render mod to deferred lightning resolves the issue.

Bur anyway, is this normal ?

No, it’s not in any way normal behaviour. Submit a bug report in editor and attach the project with instructions how unity can duplicate the issue.

Use RecalculateBounds() after you assign the mesh to a MeshFilter component. So for example in C#:

GetComponent().mesh = aMeshObject;
aMeshObject.RecalculateBounds();

This way it will recalculate renderer bounds.

1 Like