Model.GetMaterial

Material GetMaterial(int subsetIndex)

   
int subsetIndex Index of the model subset to get the Material for, should be less than SubsetCount.
RETURNS: Material A link to the Material asset used by the model subset at subsetIndex

Gets a link to the Material asset used by the model subset! Note that this is not necessarily a unique material, and could be shared in a number of other places. Consider copying and replacing it if you intend to modify it!

Examples

for (int i = 0; i < model.SubsetCount; i++)
{
    // GetMaterial will often returned a shared resource, so 
    // copy it if you don't wish to change all assets that 
    // share it.
    Material mat = model.GetMaterial(i).Copy();
    mat[MatParamName.ColorTint] = Color.HSV(0, 1, 1);
    model.SetMaterial(i, mat);
}