Search Unity

Can't fix bug with ReorderableList

Discussion in 'Immediate Mode GUI (IMGUI)' started by GinoMan2440, Apr 7, 2021.

  1. GinoMan2440


    Feb 14, 2018
    I'm on Unity 2020.2.5f1 and I'm trying to write a property drawer for Naninovel. Not an external one, but one that is built into the library to contribute to the author. In testing the drawer, I noticed some very undesirable behavior and I can't for the life of me figure out how to fix it.

    The bug: When you create a new item in the list, and give any of its text boxes a value, and then create another entry, it automatically clones the last element in the list. Maybe this is useful in some cases, but it doesn't seem to be a desirable default behavior. But that's how the editor is coded by Unity.

    Ok. So maybe I can fix this somehow by creating another property drawer for the List type? Nope! Not allowed. Unity completely ignores the list type and does nothing different if you create such a drawer despite it not being a syntax error.

    Ok. Maybe I can get around this by creating a passthrough type that derives from the specialized list type. Nope. That makes the list disappear completely and OnGUI STILL doesn't run as evidenced by a blank console despite a Debug.Log statement in the method.

    Ok, hmmmm What to do? Is there another attribute I can use on the property itself to tell Unity 'Hey, this drawer I've included as a parameter to the attribute, use that as this property's PropertyDrawer. Nope. Nobody knows of such a thing and even if there were Unity's docs are so sparse and obtuse that I'd never find it.

    Ok. Really? Is there anything in the docs that might help me? No. No there isn't.

    Odin Inspector? Sure! but they don't have a redistributable so that I can include it in the plugin I'm contributing to and they're paid so it's not like I can try to sell the author on making it dependent.

    So I can't modify the undesirable behavior, and worse, I can't override the property drawer itself to create my own list inspector. I'm at my wits end, it cannot possibly be that hopeless. Can someone help me?