Getting mesh material length

Hi, I’m making a character customization screen, and I have some articles of clothing that have 1 material, and some that have 2, like a shirt with colored sleeves. So when you swap between meshes with different amount of materials, it should change the length of the array on the skinnedmeshrenderer to be the correct size. How can I do that? I think I need to know how many materials are on the fbx, but I can’t seem to get that sort of information from a Mesh.

You need to change the materials manually. It won’t change if you just swap it out.

“but I can’t seem to get that sort of
information from a Mesh.”

You can store the materials and the mesh on the prefab or scriptableobject. And then you can access the materials and the mesh from there to replace the original mesh.

So if the player want to change to Cloth B from Cloth A. Get Cloth B reference from Cloth B prefab or scriptableobject then replace the Cloth A mesh and the materials with Cloth B.