Search Unity

Bug Problems when reordering lists with elements of different types.

Discussion in 'Editor & General Support' started by pokelocos, Mar 14, 2023.

  1. pokelocos

    pokelocos

    Joined:
    Nov 9, 2015
    Posts:
    54
    I have a list of modules that inherit from a parent module, and I have no issues with that. The data of each module is displayed in the list without any problems, as shown in the following image.

    upload_2023-3-14_16-28-43.png

    The problem arises when attempting to use the list's reorder function. When moving elements, one of them is deleted, and the list ends up showing two elements that reference the same element in the list. This also deletes the information that was stored within the object that was overwritten.

    upload_2023-3-14_16-32-41.png

    Is this error documented? Does it have to do with my implementation or how reorderable lists work?
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,935
    Is this a
    SerializeReference
    collection? And are the any custom inspectors at play here?

    Last I remember Unity's SerializeReference support was not very existent.
     
  3. pokelocos

    pokelocos

    Joined:
    Nov 9, 2015
    Posts:
    54
    yes, this is the code from the list in the images:

    Code (CSharp):
    1.         [SerializeField, JsonRequired, SerializeReference]
    2.         private List<LBSModule> modules = new List<LBSModule>();
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,935
    You don't need both SerializeField and SerializeReference. One or the other, in this case SerializeReference.

    And are the any custom inspectors at work here?
     
  5. pokelocos

    pokelocos

    Joined:
    Nov 9, 2015
    Posts:
    54
    "No, the information I'm working with is inside a serializable object [system.Serializable], and it's inside a scriptableObj . I'm not using a custom editor, it's directly what the scriptableObj displays.
     
  6. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,935
    Well I suppose drop the SerializeField attribute and see if that changes anything.

    Otherwise probably just a bug in Unity's default handling of SerializeReference. You really need some kind of addon support to make use of that attribute unfortunately.

    Might be worth a bug report? Iunno. I would just get Odin inspector.