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

Parent alpha affect children

Discussion in 'UGUI & TextMesh Pro' started by topofsteel, Mar 11, 2015.

  1. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    I'm trying to fade my interface in when the mouse goes over it by using a lerp on the alpha. But the panel alpha does not affect the children UI elements. How can I accomplish this? Thanks.
     
  2. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,663
    Your gonna have to change each one individually I imagine. Like maybe have groups of them in methods that fade them in sets if you need to, but really the parent child relationship of objects doesn't carry over any changes directly from parent to child (well I guess transform doesn't count) unless you code it to do so. Make variables for each object in the interface, and fade them one at a time (even if there's methods like FadeTopGroup() that handles groups of them at a time).

    Good luck!
     
    _TheFuture_ likes this.
  3. BinaryX

    BinaryX

    Joined:
    Aug 4, 2014
    Posts:
    55
    You can put a Canvas Group on the parent object and change that component's alpha. It will change the alpha of the parent object and of all its children that have Image components at the same time.

    Parent (with Canvas Group)
    -- Child1
    -- Child2
    -- -- ChildOfChild1

    All will have their alpha value changed.
     
    _TheFuture_, esbenrb, OVIOAli and 5 others like this.
  4. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    Awesome, thanks!
     
    redronka likes this.
  5. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,663
    Oh, I didn't know that, thanks @BinaryX
     
  6. raglet

    raglet

    Joined:
    Nov 22, 2015
    Posts:
    30
    BUMP

    Is there a way to do this for non UI gameobjects that have Sprite Renderers? Have the parent control the alpha of all children?