Setting opacity for a group of/children elements

Hello,

I am trying to find out if there is a nice way, or best practice to set the opacity of children elements to match the parent element. I noticed that opacity is not inherited (i.e. when I set the opacity of an image element to 0, the children elements such as text or other images are still visible).

Does anyone have any suggestions of a clean way to accomplish this?

Thanks,
Justin

Hi @justinISO,

What I’d do is search for all children element components using the findComponents(“element”) method. Then loop through the results and set the opacity on each element.

https://developer.playcanvas.com/en/api/pc.Entity.html#findComponents

2 Likes

Thanks for your response!

That looks like a solution I can use!

1 Like