0
\$\begingroup\$

I have a character prefab for a civilian with 5 materials. Each one should be a random color but I don't want a new material for every civilian in the game. I asked a question earlier and had a good answer. However I was pointed towards this question with MaterialPropertyBlocks. This is the code I currently have:

void Start () {
    Color newShirtColor = shirtColor[Random.Range(0, shirtColor.Length)];

    MaterialPropertyBlock props = new MaterialPropertyBlock();
    props.AddColor("_Color", newShirtColor);
    GetComponent<SkinnedMeshRenderer>().SetPropertyBlock(props);
}

It works really well but the color is assigned to the whole mesh. How can I do this for each of the 5 materials on the object so that it only changed the color for the assigned parts of the mesh, with only one material for each section?

\$\endgroup\$
0
\$\begingroup\$

I had a great answer over here at the unity forums. In short he basically said to use a texture with different colors on each channel and use that as a factor for each section of the character, thus sort of separating out the mesh, without actually separating it.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .