Applying color/alpha to multiple sprites

I have this structure for a GameObject (instanced from a Prefab):


Each body part have a SpriteRenderer and “Character 1” is a funny looking humanoid. Everything works fine and I can animate the parts together with an Animator inside the root object.

Now, my problem: I want to add a color+alpha effect to the composition (example: flash in red when damaged, fade to transparent when dead). How can I do it? I see these options:

  1. Use “GetComponentsInChildren”, loop thru it and apply effect to all parts individually;
  2. Use the Animator to apply the color for each child;
  3. Use some nice component I’m not aware about that applies it recursively for me. Just like CanvasGroup does for GUI objects.

I obviously want the third (or I wouldn’t be asking :wink: because, by using 1st or 2nd, individually semi-transparent parts will overlap each other while playing the death animation.

Have you tried making a new Sprite material and assigning that to all the sprites? you can change the tint and alpha of the material and it will affect all the sprites. Otherwise I think you are best of with option 1. As for option 3 a lot of Unities Component are just scripts anyway so you can basically write it your self (option 1 again).

I know this is an old question but if anyone’s still looking for something like this I wrote a script and posted it here with an explanation of the kinda things it can do at the bottom of the post. The animator I’m working with needed to be able edit groups of sprites in the editor, but I added functions that could be used at runtime for myself so I could set colours, sorting layers and sorting order on sets of multiple sprites.

It suits our needs pretty well - not all of our characters’ sprites can be kept neatly in one game object so attaching the sprite renderers in the inspector makes sense. If you wanted it to automatically get the sprite renderers from children of a container game object then it wouldn’t be too hard to edit the code.

Hope somebody finds it useful.

The pastebin link is here.