UInt32 IndexFormat Mesh.SetIndexBufferData cause the index count become zero

I use the following code to set the Capsule Mesh index buffer:

        Mesh mesh;
        int[] index_buffer = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
        void Start()
        {
            mesh = GetComponent<MeshFilter>().mesh;
            mesh.SetIndexBufferParams( 9, IndexFormat.UInt32 );
            mesh.SetIndexBufferData( TestGenIndexBuffer( cur_quad_count ), 0, 0, 9 );
        }

However, the render result disappear, and the index count turns to zeroDebug.Log( mesh.GetIndexCount( 0 ) );


Solved. So the problem was that With the UInt32 format index, the mesh’s submesh info is uninitialized by default, and you have to set it manually as it said in the doc. Unity - Scripting API: Mesh.SetIndexBufferParams (unity3d.com)

mesh.SetIndexBufferData( new[] { 1, 1, 1 }, 0, 0, 3 );
//Followed by this single command
mesh.SetSubMesh( 0, new SubMeshDescriptor(0, 3) );

But with the default format UInt16, the submesh don’t need to be set for setting the index buffer.
Probably because the sbmesh info is cleared when change the format to UInt32 with this mesh.SetIndexBufferParams( 3, IndexFormat.UInt32 );.

And initing the submesh inside is probably one bonus mesh.SetIndices dose more than mesh.SetIndexBufferData.