arimger / Unity-Editor-Toolbox

Tools, custom attributes, drawers, hierarchy overlay, and other extensions for the Unity Editor.
MIT License
1.7k stars 125 forks source link

Some Attributes are not Co-Existing. #71

Closed Zenodeon closed 1 year ago

Zenodeon commented 1 year ago

I noticed some Attributes are not Co-Existing like for eg [Disable] and [ShowIf(...)] which ever is declared first will override the next one.

So if [Disable] is declared first and then [ShowIf(...)]. The variable is always shown even if showif is false but only in readonly state. and [ShowIf(...)] with [Disable]. The variable is shown based on showif condition but not in real only state.

arimger commented 1 year ago

You can have only one conditional attribute on a property, this is by design.

Zenodeon commented 1 year ago

Any Particular reason for this? I would like them to co exist.

arimger commented 1 year ago

Every conditional drawer returns in what state the property should be: hidden, visible, or disabled. Supporting multiple conditional drawers, in this case, would require additional logic to resolve situations like what to do if one drawer wants to hide property and the next wants to disable it.

What exactly do you want to achieve with [Disable, ShowIf]? Maybe DisableIf would be better? If you want to have something really custom you can easily create your own conditional attribute & drawer, here is an example: https://github.com/arimger/Unity-Editor-Toolbox/blob/master/Assets/Editor%20Toolbox/HOWTO.md

Zenodeon commented 1 year ago

I require this in one of our custom tools, where I am displaying fields based on the enum.

So basically based on the enum, i am showing the field in read only state.

It works out of the box with naughty attributes, but as this plugin has more useful features, i decided to migrate to this plugin.

Will see if can make the custom attributes for this.

Zenodeon commented 1 year ago

Oh, there is an attribute called ShowDisabledIf, this is what i was looking for. Lollll

You should mention this in the read me file.

arimger commented 1 year ago

I wanted to keep README.md as an example and general overview source and the Wiki as a "documentation" but I don't have time to make it properly. Anyway, thanks, I will add information about all conditional drawers to the README.