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

ConditionalField does not hide layer and tag attributes #57

Closed
TheXRMonk opened this issue Feb 3, 2020 · 6 comments
Closed

ConditionalField does not hide layer and tag attributes #57

TheXRMonk opened this issue Feb 3, 2020 · 6 comments

Comments

@TheXRMonk
Copy link

As the title says - would be nice implementation :)

@Deadcows
Copy link
Owner

Deadcows commented Feb 3, 2020

Well, such issue were opened once, but I considered this behavior is "intended".
Now I think that such thing would be certainly nice to have 👌🏻 so thanks you for bringing this up.
I'll implement this in a few days I believe, I don't have much time at the moment

@TheXRMonk
Copy link
Author

Cool thanks! Will make it easy to make components that can check layers/tags or not. :)

@Deadcows
Copy link
Owner

Deadcows commented Feb 5, 2020

Oh dang, I completely misunderstood what you requested for some reason (probably I should sleep a bit more 😅). I though you wanted to hide Separator or Header along with the property.

Ok then, I was unable to reproduce your issue.
Can you share your code?

    public bool A;
    [ConditionalField("A"), Tag] public string TA;
    [Tag] public string TB;

@TheXRMonk
Copy link
Author

Apparently, tag needs to be the last attribute assigned. In this code, the conditionalfield for Tag works, but not for Layer;

public bool checkTag;
[ConditionalField(nameof(checkTag)), Tag]
public string CollideWithTag = "Untagged";

public bool checkLayer;

[Layer, ConditionalField(nameof(checkLayer))]
public int CollideWithLayer;

@Deadcows
Copy link
Owner

For now I figured out that ConditionalField should always be the first attribute. I experimented with order, like this:
public bool B; [Tag(order = 1), ConditionalField(nameof(B), order = 2)] public string BB;
but strangely with such setup fieldInfo of PropertyDrawer becomes null.
I'll leave this issue to figure out null problem later, for now I'll suggest to simply keep ConditionalField the first attribute.

Hopefully this will work in your case 🙄

@Deadcows
Copy link
Owner

one of the previous changes I made in ConditionalField should fix this issue

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

2 participants