Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] What about a LayerMask attribute? #341

Open
NumidWasNotAvailable opened this issue Oct 1, 2022 · 2 comments
Open

[Request] What about a LayerMask attribute? #341

NumidWasNotAvailable opened this issue Oct 1, 2022 · 2 comments

Comments

@NumidWasNotAvailable
Copy link

LayerMaskAttribute would decorate int fields, with the ability to generate a layer mask. The value could be used for raycasting, for instance.

This would look like EnumFlagsAttribute, applied to the layers logic.

What do you think about it?

Again, I can propose an implementation.

@Henri-J-Norden
Copy link

I implemented this in my LayerMask branch with [Layer(mask=true)] or [SortingLayer(mask=true)]. There is also a [XRILayer(mask=true)] for the XR Interaction Toolkit in the LayerMaskXRI branch.

It should also be easy to add new LayerMask types, you just have to subclass
BaseLayerAttribute and provide correct implementations for:

string[] GetLayers();
int NameToLayer(string layerName);
string LayerToName(int layer);

Might make a pull request later, but it doesn't look like the owner is active anymore...

@TylerTemp
Copy link

So why not just:

public LayerMask myLayerMask;

{0HO3T7%}F(NXPOPV2E)B

this value can also be directly used as raycast parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants