Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

How to fade a game object with all its children (Sprite Renderer / Image)?

Discussion in 'Scripting' started by dev_mp, Jan 31, 2022.

  1. dev_mp

    dev_mp

    Joined:
    Oct 30, 2020
    Posts:
    10
    I want to make fade in/outs for game objects with different Sprite Renderers (or Images) amongst its children, like an inventory or detailed (zoomed) views of environment items.

    I don't want to fade all these objects individually as an ugly overlap effect will be visible while fading. I would like it to fade as a single Sprite Renderer / Image.

    Any idea on how to achieve this?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,369
    One way is to strike all the sprites to a single RenderTexture at full opacity, then use that texture while changing its alpha.

    See enclosed demo of this.
     

    Attached Files:

    TimPham likes this.
  3. dev_mp

    dev_mp

    Joined:
    Oct 30, 2020
    Posts:
    10
    Hey, thanks a lot Kurt. I will take a look at your demo and see if I can "translate" it to what I need. =)