Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to change alpha on a sorting group as a whole

Discussion in '2D' started by rarac, Feb 25, 2021.

  1. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    I have multiple sprite renderers layered in a sorting group

    if I change the alpha in each sprite renderer you can see through every layer

    instead i wanted to apply the alpha change on the group as a whole, as if it was a single sprite

    is this possible or do I need some workaround, like creating a full sprite with no layers?

    here is an image of what i want if the explanation was not clear:

    Untitled-1.png
     
  2. Derekloffin

    Derekloffin

    Joined:
    Mar 14, 2018
    Posts:
    322
    Pretty sure you'll have to make your own solution for this. You can either have a data struct somewhere where everything from a particular layer is stored and you run through that to alter it, or you can scan all your gameobjects and look for those in that sorting layer (this will probably getting rather slow if you have lots of gameobjects but does have the advantage that you don't have to maintain it manually).