- Home /
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.
Answer by socialtrens · Sep 09, 2021 at 06:52 PM
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.
Your answer
Follow this Question
Related Questions
Materials on an imported mesh 1 Answer
Blender UV Material? 1 Answer
How to make a cube with metallic look and soft edges [pic included] 1 Answer