Closed MPierer closed 6 months ago
When writing this project I did think about this feature but decided to not do it cuz I didn't feel necessary.
So, seems like this feature is more important than I thought...
OK, to roundup:
Odin:
NaughtyAttributes:
EButtonEnableMode
, only for buttons.
So sounds like a necessary feature
Thanks for consideration! Well, yes I had some of these attributes in mind, but my point was more like, allow SubClassing of HideIfAttribute or ReadOnlyAttribute. Let's have the ReadOnlyAttribute for example.
We could then simply subclass the ReadOnlyAttribute with
public class DisableInPlayModeAttribute: ReadOnlyAttribute
{
protected override bool isDisabled() { return Application.isPlaying; }
}
// also implement a dummy custom property drawer, as the Saints drawers are not used for Subclasses currently
[CustomPropertyDrawer(typeof(DisableInPlayModeAttribute): ReadyOnlyAttributeDrawer
{
// implement c'tor...
}
Sorry I wrote in a hurry and didn't explain very well.
Yeah if the attribute drawer can have a better inherent-able API it'll be very convent. During the developing I did changes some part to make it easier.
However, I'm not very good at API design that focusing on extending. So at this point:
This is my answer to this issue about "easier custom(or extend) attribute)
As an example of this, the ShowIf
, HideIf
, DisableIf
, EnableIf
have exposed the API for convent extending. See:
As a reference. Well, it's not documented and the API might change in the feature.
Feel free to comment or open new issues if you have other ideas, or improved ideas for this issue.
I would like to add attributes like HideInPlayMode or ReadOnlyInPlayMode or any other condition. I am aware that I can use the existing attributes and use callbacks. But these callbacks have to live inside the MonoBehaviour or ScriptableObject, meaning I would have to add this callback in every MB or SO I would like the attribute to be used. Subclassing the ReadOnlyAttributeDrawer is also not a suitable thing, because there are different code-paths for IMGUI and UIToolkit (GetAndVisibility and GetShow). So maybe some solutions would be: