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

How to create custom GroupAttributes #3

Open
JefferiesTube opened this issue Jan 28, 2022 · 5 comments
Open

How to create custom GroupAttributes #3

JefferiesTube opened this issue Jan 28, 2022 · 5 comments

Comments

@JefferiesTube
Copy link

I wanted to use MarkupAttributes to allow me to overcome a limitation of PropertyDrawers.
I have multiple properties like this:

public SomeClass PropertyA
public SomeClass PropertyB
public SomeClass PropertyC

I want to divide them into several groups like this:

[MyAwesomeGroup("Category A")] public SomeClass PropertyA
[MyAwesomeGroup("Category B")] public SomeClass PropertyB
[MyAwesomeGroup("Category A")]public SomeClass PropertyC

I want to create a custom drawer that creates a single(!) editor for each group (so in this example even though I have 3 properties, I end up with 2 editors).

Is this possible with MarkupAttributes? It looks comparable to the TitleGroup-Attribute.
Is there any information how to extend your system with custom attributes?

@gasgiant
Copy link
Owner

What do you mean by two editors? You mean PropertyA and PropertyC should have the exact same value?

@JefferiesTube
Copy link
Author

No, but if possible I'd like to execute the editor code per group only once.
To be more specific: I would like to draw a button for each group that opens a popup menu (comparable to the way the EventTrigger editor from the Unity UI works)

@gasgiant
Copy link
Owner

There is no easy way to make your own group type. If it is a very specific editor - one off thing - I think writing it as usual is the way. You could use MarkupGUI class to create MarkupAttribute style grouping in this custom inspector.

There is also a way to add custom things to the inspector before, after or instead of any property https://github.com/gasgiant/Markup-Attributes#custom-marked-up-inspectors

You could do something like this

[TitleGroup("Category A")] 
public SomeClass PropertyA
public SomeClass PropertyC

[TitleGroup("Category B")] 
public SomeClass PropertyB

and then make a custom MarkedUpEditor that would manually add buttons after, say, properties C and B. But, obviously, you would have to add a button to each group you create manually.

@JefferiesTube
Copy link
Author

But this would not prevent the properties from being drawn in the editor.
If I could add something to the wishlist for this library it would be make it possible to add custom attributes. I assume that this is rather difficult, but it would allow to write really clean things that (so far) only Odin is capable of (and Odin cannot be included in custom AssetStore products)

@gasgiant
Copy link
Owner

gasgiant commented Jan 28, 2022

Could you, please, elaborate on what you mean by the custom attribute here? Or maybe point to Odin documentation for an example.

Do you mean things like a TitleGroup modification that adds a button below it or something more complex?

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