Hi,
I have a character prefab which has a script that changes vert.001 child game object material, this is the hierarchy:

This character prefab’s script has vert.001 as a serialized parameter:

I want to instantiate a few characters and then change each one’s vert.001 material based on the team their are on
simplified code:
private void SetTeamColorInModel()
{
Renderer playerRenderer = model.GetComponent<Renderer>();
Material customMaterial = playerRenderer.material;
customMaterial.SetColor("_Color", Color.gray);
}
The problem is I got the following error:
Not allowed to access Renderer.material on prefab object. Use Renderer.sharedMaterial instead UnityEngine.Renderer:get_material () CharacterScript:SetTeamColorInModel () (at Assets/Scripts/Characters/CharacterScript.cs:110)
What is the right way of changing a child object material?