CustomAddFunction in combination with TableList not working

Issue #437 closed
Rainer Bernhardt created an issue

When using a custom add function on a list via the ListDrawerSettings attribute, I would assume it works with the TableList attribute.

The following example demonstrates that pressing the + button on ListA will not add a value with 2, where in ListB it will add with "2" as a value.

public class Example {
    [TableList]
    [ListDrawerSettings(CustomAddFunction = "AddValueToA")]
    public List<int> ListA = new List<int>();

    [ListDrawerSettings(CustomAddFunction = "AddValueToB")]
    public List<int> ListB = new List<int>();

    private void AddValueToA() {
        ListA.Add(2);
    }

    private void AddValueToB() {
        ListB.Add(2);
    }
}

Comments (6)

  1. nick martel

    Still an issue today, just had a little moment here wondering why my custom add function didn’t work.

  2. Antonio Rafael Antunes Miranda

    The ListDrawerSettings attribute is not compatible with the TableList attribute as of now. There are plans to fully support it for TableLists during/after the switch to Unity’s new UIElement system.

  3. Dan Vicarel

    Hi Antonio, thanks for the update, glad to know this is on the team’s roadmap. If this is expected behavior then it really should be documented. Right now, the Odin docs for ListDrawerSettingsAttribute just say “Customize the behavior for lists and arrays in the inspector” with some sample code. There is no indication that it doesn't work for TableList (and now I'm curious if there are other list attributes that it doesn't work with).

  4. Antonio Rafael Antunes Miranda

    I think the reason that it is currently not listed anywhere, is that you technically can use the ListDrawerSettings attribute when you use the TableList’s hamburger button that switches into normal list drawing mode. However I agree that there should probably be a note about it not working in table mode. I’ll bring it up 🙂

  5. Antonio Rafael Antunes Miranda

    Hey Restu, as I mentioned above the TableList attribute and ListDrawerSettings are incompatible, this is not a bug, they are just 2 different drawers with different behavior. We plan to add support for ListDrawerSettings on TableLists in the future, but until then you’ll have to use another method to customize add behavior like a button above or below the drawer.

  6. Log in to comment