Search Feedback

31
votes

Custom element size in Reorderable List.

Editor

-

-

It is currently impossible to add Foldouts and "growable" Property Drawers in Reorderable Lists. Saving the individual elements size would be trivial and open up many possibilities.

Thank you

Comments (5)

  1. 41b02dbd30f08d896b361aabf9fa7032?d=mm

    Artifact-Jesse

    Oct 04, 2016 17:57

    I created a fork of the Gist that is a little more complete and generic as an example (at least for my purposes). There are also some notes in there for how to improve it. Hope someone else finds it useful!

    https://gist.github.com/JesseHamburger/3d17f3892e671a4ae17873ec4e8a0926

    @DREAMINGINSPIRIT - I couldn't get mine to work with SerializedProperty.GetPropertyHeight() but I was using a Custom PropertyDrawer for the data class that I was trying to display and the override method I created for it didn't seem to be getting the job done. Still haven't determined if this is a bug or if I just wasn't implementing it correctly.

  2. 58a66718ca52b269ed4882f779a11427?d=mm

    DreamingSpirit

    Jul 17, 2016 15:39

    This also works if you properly define your propertyheight (where list is your ReordableList):

    list.elementHeightCallback = (index) =>
    {
    var element = list.serializedProperty.GetArrayElementAtIndex(index);
    return EditorGUI.GetPropertyHeight(element);
    };

  3. 56838555f526cb1451a57ebcaf4b98ef?d=mm

    Jeiel

    May 17, 2016 09:59

    ReorderableList.elementHeightCallback seems to only be available from 5.3 onward.

  4. Cccc8a4abc52308ff659725ef5292de0?d=mm

    Socapex

    Mar 13, 2016 21:48

    @Malqua OH MY, this is looks promising.

    Seems I don't get mails for responses on here, so this is a little late. I will try your solution but I have a feeling it might not work in my situation (dragging to reorder was really messing up in my tests). Anyways I will see if it works :)

    I created a Gist because pastebin is not really future proof: https://gist.github.com/Socapex/1d9b45507464681d530b

  5. 9ae25d7eeb5f9a26ad60b53dc3808cff?d=mm

    Malqua

    Dec 14, 2015 23:00

    This is already possible using elementHeightCallback. Save an array of floats, assign the value in drawElementCallback, look up the value in elementHeightCallback and return it. Remember to resize the array when you add or remove a new element.

    Here's an example gif: http://i.imgur.com/fIbBorr.gifv
    And here's a code sample: http://pastebin.com/WhfRgcdC

    I use active to expand the height, but you could create a boolean array in the same way as the floats and display a foldout instead.

    The only oddities I've encountered is that dragging to rearrange the order will only take into account the element height for index n to n+1, and you sometimes can't move an element up into the 0 index.

Your opinion counts

Help us make things better. Share your great idea for improving Unity or vote for other people’s.

Log in to post a new idea

Categories

All

(8365)

2D

(197)

Ads

(31)

AI & Navigation

(50)

Analytics

(80)

Animation

(275)

Asset Store

(189)

Assets

(474)

Audio

(145)

Cloud Build

(86)

Collaborate

(11)

Docs & Tutorials

(172)

Editor

(1936)

Everyplay

(13)

Game Performance Reporting

(10)

General

(751)

Graphics

(699)

GUI

(335)

Input

(138)

Licensing

(68)

Networking

(141)

Physics

(314)

Platforms

(394)

Profiling & Optimization

(63)

Runtime

(146)

Scripting

(942)

Terrain

(149)

WebGL

(126)