- Home /
Add shaders into Array based on Material Array
Basically, I need to catalogue all the shaders I'm using for some objects which use multiple materials, and this didn't save the shaders. What am I doing wrong??? ChildInf is an array that holds object, renderer, material[] and shader[].
void SetShaders()
{
for (int i = 0; i < childInf.Length; i++)
{
childInf[i].render = childInf[i].childObj.GetComponent<SkinnedMeshRenderer>();
childInf[i].mats = childInf[i].render.materials;
for (int s = 0; s < childInf[i].mats.Length; s++)
childInf[i].shadersforMats[s] = childInf[i].mats[s].shader;
// we saved all of our original shaders
}
Debug.Log("Shaders set");
}
Everything up until this line childInf[i].shadersforMats[s] = childInf[i].mats[s].shader; works just fine.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612041734im_/https://answers.unity.com/themes/thub/images/avi.jpg)