- Home /
Is there a way to tell if a Material is visible?
Is there any way to tell if a Material is visible?
I have a material that is updated by a script. I don't want that script to run if the material is not actually being used (I switch it off). I have a lot of different objects which can use this material, not all of them will use it at the same time. I'm pretty sure I know how to tell if a Mesh is visible, but is there a (good) way to tell if a Material is visible?
Answer by Eric5h5 · Sep 11, 2010 at 12:56 AM
Probably the easiest way is to have a central variable that keeps count of the number of objects with the material in question that are visible. For each object, have a script that increments the variable using OnBecameVisible, and decrements it using OnBecameInvisible. Any time the variable is 0 it means that no objects using the material are visible.
Your answer
