Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Reorderable List broken for me in 2020.2.6+

Discussion in 'Immediate Mode GUI (IMGUI)' started by CptKen, Mar 9, 2021.

  1. CptKen

    CptKen

    Joined:
    May 30, 2017
    Posts:
    216
    Hi,

    I have been using IMGUI Reorderable lists in my plugin since 2018.4 and they have worked fine until now.

    In Unity versions 2020.2.6+ they have suddenly stopped working as the serializedObject is being disposed for some reason.

    upload_2021-3-9_10-39-13.png

    I get this error pretty much anytime I modify the list by adding a new element or trying to delete an element. Oddly it doesn't occur when re-ordering elements. It also triggers on ReorderableList.DoLayoutList() immediately after deleting the element.

    Is anyone else having this issue? Does anyone have a quick fix? The fact that it has randomly started occurring in a Unity minor version makes me think it is an introduced bug. Any help is greatly appreciated.
     
    Last edited: Mar 9, 2021
    chadfranklin47 likes this.
  2. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,077
    I'm seeing something similar in 2020.2.6+ - my Editor classes are being disposed and recreated every few seconds, seriously messing up the state of my objects.
     
  3. CptKen

    CptKen

    Joined:
    May 30, 2017
    Posts:
    216
    I found a workaround for my purposes, not sure if this will help anyone else but I'll post it here just in case.

    For my use case I create assets and add them as sub assets to a parent to help with serialization. After adding them to the object I re-import the asset to make sure it shows up properly. Originally (back in 2018.4) I called AssetDatabase.Refresh() but this was too slowed down the editor a lot at the time. However, in 2020.2+ it doesn't seem to be that slow. I replaced my re-imports with AssetDatabase.Refresh and this problem goes away for me.

    Here's an example:

    Code (CSharp):
    1.  
    2.     AssetDatabase.AddObjectToAsset(newComposite, m_data);
    3.     newComposite.hideFlags = m_spHideSubAssets.boolValue ? HideFlags.HideInHierarchy : HideFlags.None;
    4.  
    5. #if UNITY_2020_2_OR_NEWER
    6.     AssetDatabase.Refresh();
    7. #else
    8.     AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newComposite));
    9. #endif