Hi. I have a generated mesh. In that mesh 1 override material is 1 mesh section. So to put material on it, I need same number of override materials as I have mesh sections. I can add materials inside the editor to that override materials like this: https://i.imgsafe.org/1d55c01.png , but the problem is, that every mesh is different and has different number of mesh sections. So I need to create this dynamically from code.
I did try this:
_mesh->OverrideMaterials.Init(_baseMat, scene->mNumMeshes);
Which initialize the array to correct number of mesh sections, but it is initialized to null. And when I call
_dynMat = _mesh->CreateDynamicMaterialInstance(i);
I get a fatal error that index of array is invalid. It processes the 7 mats I added manualy from editor and then it stucks, cuz materials arent there anymore (just initialized values to null). So how do I assing the mat properly to use whole array?