- Home /
Scene layers as Enum
Is it possible to declare an Enum containing all the Scene's layers (which would optionally be updated if/when layers change/are added removed) ?
Basically I'm working on a little script that plays sounds when a GameObject collides with another object, and in some cases I want to check if the gameObject has collided with a Collider from a specific layer.
Ideally I'd like to be able to choose which layer from said Enum in a public variable so I won't have to code any layer-specifics into the script.
Thanks.
Layers are already stored as a bitmask- it's a very straightforward conversion. However, I wouldn't try making an enum that can be 'updated' as layers are changed or updated- once an enum has been declared, it can't be changed. Why would you have to code 'layer-specifics' into your script? There's no reason why you can't just make a public Layer$$anonymous$$ask object, and compare against that.
Your answer
