Search Unity

ReorderableList : different heights per element?

Discussion in 'Immediate Mode GUI (IMGUI)' started by SidarVasco, Apr 6, 2016.

  1. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163
    Problem: cannot get different heights for ReorderableList elements

    For my ReorderableList when the users hits the + button to add an item I want to popup an option to add a single field or a collection.

    The structure for setting that up isn't the issue. My list objects contain an enum which indicates whether it's a single ( one data field ) or a collection ( an array ).

    So I need to gui to draw something like this.

    Code (csharp):
    1.  
    2. [name][value]         <---- single
    3. [name][value1]       <-------- collection
    4.       [value2]
    5.       [value3]
    6.       [value4]
    7.       [etc   ]
    8. [name][value]          <---- single
    9. [name][value]          <---- single
    10. [name][value]          <---- single
    11. [name][value]          <---- single
    12. [name][value]          <---- single
    13.  
    Where name and value are both string inputs.

    Using ReorderableList.elementHeight seems to change the height of each element, but I was more hoping for setting the height for each field individually instead. Is this actually possible? Currently the next element is obscured by the collection as it's not drawn at the end of the collection.
     
    Last edited: Apr 6, 2016
  2. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
  3. MrMatthias

    MrMatthias

    Joined:
    Sep 18, 2012
    Posts:
    191
    Without changing the ReorderableList class this is not possible.
     
  4. jmjd

    jmjd

    Joined:
    Nov 14, 2012
    Posts:
    50
    Yes you can do this now! I recently was able to implement this. From the comments in this article, it looks like the elementHeightCallback was added in 5.3. Use the callback to return the height of each element.
     
    jjbish and TalentedYao like this.
  5. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163
    Thanks all,

    @MrMatthias It is possible though without changing source code.

    @jmjd Yes I actually used that article to make my own, but completely missed that last bit. Asked the qestion here and got fairly good answer to it as well.