[SOLVED] Header attributes in incorrect order

Using the Header attribute, sometimes the header appears in the incorrect order in the inspector window.
I have this:

    [Header("Room 902 Controller")]

    [Header("Lights with LightTransitionController")]
    [SerializeField] private Light [] realtimeLights;

The inspector shows this:


It shows the headers are not in the same order.

Is this a bug, or am I doing something wrong?

1 Like

Anything in [ ] like that is an Attribute, meaning that it applies to the member variable that follows it, just like “private” and “public” are as keywords. So, both your headers there are being applied to the realtimeLights member, and they’re just sort of being applied to a “pile” of attributes that apply to that member. So their order won’t be predictable, if they’re on the same variable.

2 Likes

EDIT: I found this thread which seems to solve the problem. Needed to specify the order of the header:

3 Likes

Just another long-standing bug at unity.

Workaround is to explicitly give the “order”

[Header(“Enter data here”, order=0)]

[Header(“Put heights here”, order=1)]

etc.

There are (obviously) various other bugs - example, you can’t “end with a header”.

1 Like

I don’t think it is a bug. AFAIK, there’s no way to retrieve an actual attribute order from the property in code via reflection.

1 Like

@VergilUa - fair enough. But, hmm; any inspector variables you put in there do appear in the same order as in the script.

Im new in unity and im confused because when I try to upload the unity build to the meta quest alpha version, it says that " no END header found" so can you guys please help me with this?