Serialized System getting all clustered in editor

image

has anyone encountered a problem like this?
I am looking for a solution on my own but no luck so far.

Steps to reproduce:

  1. add this code to your Ammo.cs

    [SerializeField] AmmoSlot ammoSlots;

    [System.Serializable]
    private class AmmoSlot
    {
    public AmmoType ammoType;
    public int currentAmmoAmount;
    }

  1. From editor, change the number of Ammo Slots to more than 1

Hi,

That seems to be a problem with the Unity Editor, not with your code or something you did. Have you already tried to restart Unity?

If the issue persists, please go to Window > Layouts and select “Default”. If you created your own layout, remove that, select “Default”, rearrange the windows and save it again. That often fixes visual problems in the GUI of the Editor.

And if nothing helped, consider updating Unity. Maybe there is a bug in your version.


See also:

Hi Nina, thank you for your super fast reponse.
Tried all of that with no luck.

Sent a bug report to Unity, we will see if this helps.
Have a good day!

This is a bug in Unity. If you don’t care for your ammo slots to be reorderable, you could add [NonReorderable]. This should fix the display issue. This attribute is only available from Unity v2020.2 onwards but I believe the reorderable lists, too

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms