How to change alpha of many shapes in once?

Hi all!

All in the title! :slight_smile:
Let’s say I have a scene with 100 cubes and what I want is to change their opacity without looping throuth all of them.
The thing is they all have to have their own material so I can’t give them the same material and just change the alpha from this mat.
So here what I tried so far which didn’t work:

  • Set a parent to these 100 cubes and play with the parent’s visibility
  • Set a multi material which contains 2 materials one specific to each cube and one common material which handle the opacity

Hope someone can help me.

If they don’t have a common material you are kinda force to do a loop.

Well perhaps not, actually. You can use observable for that :slight_smile:
you can add that to all your meshes:

mesh.onBindObservable.add(m => {
m.visibility =- 0.5
1 Like

Yes it does the trick!
Thank you.