Git Product home page Git Product logo

Comments (1)

TylerTemp avatar TylerTemp commented on June 9, 2024 1

This at this point is not possible, because NA will always render NonSerializedFields and buttons at last.

A workaround is to write a extended script. This is what i use in my project:

gist link

Delete all non-functional (because I have many other drawer extension as well).

This works on my project but because the extensions not included here, and many custom functions I used for myself, so not guaranteed it works in yours. But... you get the idea.

And add a [Ordered] to field if the order is incorrect, then the inspector will know which comes first.


Update: and this is how it looks like in my project. Note the button is in the middle of where it should be.

[SerializeField, Ordered] private int _pIntPrivateOrdered;

[Ordered]
public int pIntOrdered;

[Button("Button Text"), Ordered]
private void MethodTwo() { }

[ShowNativeProperty, Ordered] private string NativeString => "NativeString";
[ShowNonSerializedField, Ordered] private const int NonSerInt = 9;

[Ordered]
public Animator someAnimator;

[AnimatorParam(nameof(someAnimator)), Ordered]
public int paramHash;

FW}KJKN4NI(GU~HZAK`J6


Update: @AndrzejKebab I just notice that the sort function is incorrect...

Please change

_fieldWithInfos.Sort((a, b) =>
{
    // Debug.Assert(a.inherentDepth != 0);
    // Debug.Assert(b.inherentDepth != 0);
    int firstResult = a.inherentDepth.CompareTo(b.inherentDepth);
    return firstResult != 0
        ? firstResult
        : a.order.CompareTo(b.order);
});

Into:

_fieldWithInfos = _fieldWithInfos
    .WithIndex()
    .OrderBy(each => each.value.inherentDepth)
    .ThenBy(each => each.value.order)
    .ThenBy(each => each.index)
    .Select(each => each.value)
    .ToArray();

I have also updated the gist script.

(P.S. I've open-sourced my utils from my old project and published here, if you're interested please consider to have a look. The gist is basiclly this script)

from naughtyattributes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.