Link colors across multiple sprite renderes

My characters are made up of a number of different sprites and sprite renderers. (Head, body, arms, legs, ect)

I’m not really sure what words I need to be using to ask this but here it goes. Is there a way to link a set of sprite renderers so that when I change the color of one sprite, the rest of the sprites for that object are updated as well?

I don’t know of an ‘automatic’ way of doing that.

If all the body parts use the same Material you can change the material color.
But as you are using Sprite Renderers and probably using the default sprite material, this will cause all the sprites to change color.

Using individual Materials for each character will affect your batching… affect a lot :slight_smile:

I would make an script that will search and store all the SpriteRenderers of a character in Awake() or Start(). And when you need to change the sprite colors you can iterate the list and change it.

But i’m just a beginner, maybe someone has a better solution :smile:

Instantiate a material, assign it to the appropriate sprites using SpriteRenderer.sharedMaterial, and change the instantiated material’s color.

–Eric

Changing the material of a sprite will make it dont batch, that’s correct right?

I agree with you if he want to do this only with the main character, but i think that he wants to do this with other characters too, that will have ‘shared sprites’.

Thanks Eric! Instantiate was the word I think I was looking for. I will try this and report back on the batching!