When I am running my game I have a game object called universal element. I spawn this element into the game, depending on a multitude of variables, the element will have a mesh applied to it. Lets say at one moment when it spawns it it's placed in a certain location as a rock. Another moment passes the player is very far away, it'll despawn and respawn into the game near the player as a tree. Well in this case, the tree has a mesh that actually instead of being just a mesh with a single material like the rock, it'll need two materials say for the leafs and the tree trunk. This is when I need to change the material array to 2 instead of 1. Another case, I am further along in the game and the element spawns in as a building. The building has a mesh that requires 4 materials. Now I need to change the array to 4 materials instead of 1. I do all sorts of things to this element, I change its size, the textures it uses, the shaders that are active on its texture, the shader parameters (some of my shaders have methods I can call to change modify the way they behave, the rotation of the object and etc...
This is my use case. Simply put there are times that my element needs to be a rock and times where it needs to be a car, building, tree, bush, water, humanoid, space ship, etc etc all of these things use different meshes and many of those meshes have more than one material. Now If I have an element that has an array with say 10 materials but my current mesh only needs 2, the shaders and the textures do not perform right. For some reason the 8 other shaders and textures even if I do not place a texture on those material "slots" affect the other 2 shaders. In a case where I have a mesh that needs 2 materials and my element has 10 materials in the array, the textures will appear in game while I'm testing but shaders are not applied correctly, it causes errors a reflective shader for instance might not render, it'll appear as one of the shaders applied to one of the other 8 material slots that aren't in use. The same is true for the textures in the other 8 slots, they often will just appear black even if empty. So I might had placed the right texture in slot one and two but the other 8 overwrite it and the end result is black.
To make a long story short, many developers at one point or another are going to need to change the size of the Mesh Renderer component on their game object during runtime. There needs to be an action for this.
Thanks for any help you can give me - Andre