Does setting SetActive(true) in parent GameObject sets CanvasRenderer alpha of child objects to 1?
Hi,
Trying to find source of problem in UI. It's too much to describe whole logic. Overall there is a parent object which is turned on/off with ParentObject.SetActive(true/false). It has many child objects: Buttons. Depending on circumstances different sets of buttons are shown. But after the first cycle of turn on/off parent object - whole buttons get shown. Buttons are turned off with ChildObjectButton.GetComponent().SetAlpha(0)
Is it possible that after ParentObjects is set as active all child CanvasRenderers' alpha is set to 1?
Answer by igierardstimulant · Jul 19, 2016 at 03:27 AM
@nTu4Ka I've been seeing this as well. I've worked around this by setting what alpha I want in the OnEnable and OnDisable methods.
This is annoying but does seem to fix my problem of having the UI flash on for a frame when I enable a GameObject that I want to fade in.
Answer by nTu4Ka · Sep 02, 2015 at 01:57 PM
Yikes. This is some strange thing.
It is true that alpha of child objects is changed. But it is changed to 1 when ParentObject.SetActive(false) which doesn't make any sense.
I managed to find a work around by separating buttons to another parent but maybe someone knows more about this. Or maybe it's a bug.
Your answer
Follow this Question
Related Questions
How to change image of button when clicked? 2 Answers
Keep UI object disabled unless it's inside canvas 0 Answers
Make Canvas Image ignore specific game object. 1 Answer
Sprite drawing. 0 Answers
How to get Canvas renderer bounds? 1 Answer