UI CanvasRenderer SetAlpha does not set alpha of children

Am i doing something wrong?

I have an Image object, with some child objects such as Text.

I set the alpha of the Image’s CanvasRenderer, and it works for the image but the child text doesn’t change its alpha.

The same happens if you have a Panel holding child objects.

On you parent object, Panel or Image, add a component CanvasGroup.

That’s the secret - set the alpha for a CanvasGroup and it sets the alpha all the way down below it.

Note that it’s fine to just add a CanvasGroup on your actual main Canvas, if, you simply want the whole UI to be slightly transparent.

Note that you can just add CanvasGroup in the editor, and set the alpha in the editor if you wish, no problem.

public Image myImage;

// then where you want the Alpha setting

myImage.GetComponent<CanavasGroup>().alpha = 0;

That should affect all child objects as well. You might want to set BlockRaycst and Interactive to false at the same time so the image doesn’t block anything.