Search Unity

Bug MeshUpdateFlags.DontRecalculateBounds is not respected by SetSubMeshes

Discussion in 'Scripting' started by adamgolden, Sep 22, 2022.

  1. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    Per documentation,
    "The bounds, firstVertex and vertexCount values are calculated automatically by Mesh.SetSubMeshes, unless MeshUpdateFlags.DontRecalculateBounds flag is passed."

    This does work for SetSubMesh. However, when using SetSubMeshes, it does not.

    Repro (using a mesh with 1 submesh):
    1. Grab the SubMesh Descriptor from the mesh.
    2. Add a new vertex to the mesh.
    3. Add 1 to the vertexCount property of the submesh.
    4. Use either SetSubMesh or SetSubMeshes (depending on which you're testing) and pass in the DontRecalculateBounds flag.
    5. Grab the SubMesh Descriptor again from the mesh and Debug.Log the vertexCount.

    Tested in 2022.2.0b8, though it seems like something that may have gone unnoticed for a while.