Today i have find new non documented Unity 4.5 Feature. Its native UnityEditorInternal.ReorderableList!
Its very easy way to add more convenient behavior of array properties inside your Editor GUI with or without GUILayout.
Its very simple:
var reorderableList = new UnityEditorInternal.ReorderableList(List<SomeType> someList, typeof(SomeType), dragable, displayHeader, displayAddButton, displayRemoveButton);
reorderableList.DoList(rect);
//or
reorderableList.DoLayoutList()
Previously i am looking for native reorderable list inside unity, but it was have only internal access and there is no way(simple way) to add it to my own GUI
Yiakes⦠Alright, not implementing that in my package right now. Iāll stick with my own sortable collection until Unity find a way to apply it to all collection without any custom editor or property drawer.
Iām currently using a custom property drawer for generic list elements, which means that it works on a per-field basis, using a custom attribute. Unfortunately I had to use some hacks to make it work (Some reflection and some string parsing), so it doesnāt respond well to adding the attribute to other types of fields. But it works.
Hereās how Iām using it:
[ReorderableList][SerializeField] protected List<SimulationStep> m_steps = new List<SimulationStep>();
So it shouldnāt have to require a very significant code change when Unity finally makes their built-in reorderable list available.
Well, for what it is worth, my āAdvanced Inspectorā package allows every items to be of different size, or even have an expansion arrow on the left.
I noticed some of you guys mentioning the element height ā is there some way to change the height of the elements shown in the ReorderableList? I donāt care if theyāre all the same size, but I need each element taller than a single line.
// Edit: Ah, I figured it out based on @PrefabEvolution 's code sample
Hey everybody, iām actually searching a way for unselect the list programatically ⦠any idea ?? the idea is to lose the focus or/and the āisActiveā ⦠thank you !
Good try ⦠but it unselect my asset in the project panel and undisplay the inspector panel. My goal is to unselect a field on the inspector panel, without undisplaying it⦠or find a way to unselect only a field of a reordable list, or even, maybe, find a way to trigger the āselectā event on a field already selected ā¦
In the image you included in the original post, your header is shown with a foldout label and without the default ReorderableList Header GUIStyle. Can you share how you accomplished this? I have tried to mess with drawHeaderCallback but I canāt seem to change the style of the header.
PS. anyone who wants to know more about ReorderableList, check this blog post out:
I created a custom reorderable list field prior to the Unity one being exposed which is open source and can be downloaded from the following Git repository:
I use my control a LOT; perhaps others here will find it useful in their projects. I havenāt use the non-documented Unity control, but looking at the IntelliSense popup it seems to work in a different way.
This can be achieved with my control!
Iād love to know what people think of my control
Whilst the control can itself be drawn with layout or absolute position, list items are drawn using absolute position.
You can calculate the height of your list items in āreal timeā by calculating layout height inside the GetItemHeight function of a custom adaptor. With that you could probably use GUIStyle.CalcHeight.