Search Unity

ReorderableList and onReorderCallback

Discussion in 'Immediate Mode GUI (IMGUI)' started by Fenyx, Jan 23, 2015.

  1. Fenyx

    Fenyx

    Joined:
    Aug 9, 2013
    Posts:
    8
    I need to do some other stuff to my data when the list gets reordered but onReorderCallback(ReorderableList list) only gives me the list. I need, like, the index the item was previously in and the index it was moved to.

    Am I missing something or is that info just not available?
     
    IgorAherne likes this.
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    I use onSelectCallback to record the previous index (it's in list.index).

    Then in onReorderCallback I can compare this against the current value of list.index.
     
  3. Fenyx

    Fenyx

    Joined:
    Aug 9, 2013
    Posts:
    8
    Worked like a charm! Thank you so much.
     
  4. Reddoge

    Reddoge

    Joined:
    Feb 19, 2016
    Posts:
    10
    Old post but there is now a delegate called ReorderCallbackDelegateWithDetails that contains parameters: (ReorderableList list, int oldIndex, int newIndex). This seems like currently the best solution. Hopefully to those looking.
     
    VictorHHT and Malbers like this.