- Home /
Question by
jonathanturner1200 · Jun 09, 2020 at 08:53 PM ·
errormaterialsruntimeparametersskinnedmeshrenderer
How to use GetMaterials function with skinned mesh renderer
I'm trying to get the materials from the skinned mesh renderer using the 'GetMaterials' function but it wants a parameter 'm' that corresponds to a list. Here is the error: There is no argument given that corresponds to the required formal parameter 'm' of 'Renderer.GetMaterials(List).' I am trying to get the materials to reassign them at runtime. I'm trying to avoid just calling the materials function because I recognize that GetMaterials is better for performance. What parameter should be used for this function? 'preciate it.
Comment
Answer by TallPaulUK · Dec 02, 2020 at 11:55 AM
Just came across this 11 years later but for anyone who is still having this issue it works like this
MeshRenderer meshRenderer = GetComponent<MeshRenderer>();
List<Material> materials = new List<Material>();
meshRenderer.GetMaterials(materials);