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

Feature request - order for box groups #381

Open
novavision opened this issue Jan 26, 2024 · 3 comments
Open

Feature request - order for box groups #381

novavision opened this issue Jan 26, 2024 · 3 comments

Comments

@novavision
Copy link

novavision commented Jan 26, 2024

First of all thanks a lot for your asset, it is just a gem! Made my project looks much more organized.

Working with NestedAttributes for a pretty long time I experienced that I miss order option for some attributes .
For example BoxGroup - I have about 4 inheritors and each of them have some specific serialized fields I place under the BoxGroup. In some cases I wish to see very specific BoxGroup on top of all others just for better accessibility and prettier visuals. That's also because some classes have too many fields and may take the area of entire screen height. Foldout BoxGroup may be very handy here as well, but that's a different story.

I there an option to add some order parameter to BoxGroup attribute?

@TylerTemp
Copy link

TylerTemp commented Feb 7, 2024

Unfortunately this project hasn't merge PR for years... Here is one that might fit your need (though not exactly what you want) (It's very new so might be buggy)

to demo:

public class RootClass : MonoBehaviour
{
    public string root1;
    public string root2;

    [Layout("RootGroup", ELayout.Title | ELayout.Background | ELayout.TitleOut)]
    public int firstInt;
    [Layout("RootGroup")]
    public int secondInt;

    public string rootAfterGroup;
}

public class Sub1 : RootClass
{
    [Layout("RootGroup")] public int sub1ToRoot;

    public string sub1Item1;

    [Layout("Sub1Group", ELayout.Title | ELayout.Background)] public int sub1Group1, sub1Group2;

    public string sub1ItemAfterGroup;
}

public class Sub2: RootClass
{
    [Layout("RootGroup")] public int sub2ToRoot;

    public string sub2Item1;

    [Layout("Sub2Group", ELayout.Title | ELayout.Background)] public int sub2Group1, sub2Group2;

    public string sub2ItemAfterGroup;
}

Result:

image

So the field stay at the position by the order of declaration and inheriting, but also gets pumped to the first group when necessary.

As for "to see very specific BoxGroup on top of all others", the Ordered attribute might help

@novavision
Copy link
Author

@TylerTemp looks cool, thanks. Did I correctly understand that your asset expand same base functionality NaughtyAttributes has? In other words I don't need to do some migration renaming attributes?

@TylerTemp
Copy link

TylerTemp commented Feb 9, 2024

@TylerTemp looks cool, thanks. Did I correctly understand that your asset expand same base functionality NaughtyAttributes has? In other words I don't need to do some migration renaming attributes?

Unfortunately, the renderer behavior (demonstrated here, the Layout), is the Editor level function. I quote from NA's documents:

The attributes that won't work in your custom editors are the meta attributes and some drawer attributes such as ReorderableList, Button, ShowNonSerializedField and ShowNativeProperty.

the meta attributes, or the Editor level functions I mentioned here, is NOT compatible with each other: Odin, NaughtyAttributes, MarkupAttributes, SaintsField.SaintsEditor -- only one can work at a time.

In short, there are only 3 options possible:

  • Switch to another editor extender like SaintsField, or Odin (as it provide the Order function which suits your needs). But you need to learn and switch all the stuff...

  • Fork and modify NaughtyAttributes like in this issue, which re-ordered the meta attributes rendering (gist link here). As it does not fix everything because of the limitation from C#, you may need to do more work to achieve what you want

  • Using the mix of SaintsField and NaughtyAttributes, but make SaintsField.SaintsEditor as your main Editor class. There are one advantage and two disadvantages of this:

    1. Good news: any attributes in NaughtyAttributes which are NOT meta attributes, you can use it as expected. Nothing need to be changed.

    2. Bad news: You need to manually change these meta attributes:

      Button -> SaintsField.Playa.Button

      ShowNonSerializedField -> SaintsField.Playa.ShowInInspector

      ShowNativeProperty -> SaintsField.Playa.ShowInInspector

      ReorderableList -> nothing. Unity default uses ReorderableList now

      BoxGroup -> SaintsField.Playa.Layout

      Foldout -> SaintsField.Playa.Layout

      EnableIf / DisableIf -> SaintsField.ReadOnly

      ShowIf / HideIf -> SaintsField.ShowIf/SaintsField.HideIf

      Label -> SaintsField.RichLabel

      OnValueChanged -> SaintsField.OnValueChanged

      ReadOnly -> SainsField.ReadOnly

      MinValue / MaxValue -> SaintsField.MinValue/SaintsField.MaxValue

      Required -> SaintsField.Required

      ValidateInput -> SaintsField.ValidateInput

      Some APIs are the same as NaughtyAttributes, but some are not...

    3. Bad news: the compatible is not well tested. Nuh, in fact, the whole project is not well tested. I use it in my personal project, and my company's project. But it's far not well tested compared to NaughtyAttributes

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