Reorderable List Control for Unity
- Namespaces
- Rotorz.ReorderableList
- ReorderableListControl
- ReorderableListControl..::..ItemDrawer<(Of <(<'T>)>)>
ReorderableListControl..::..ItemDrawer<(Of <(<'T>)>)> Delegate
Invoked to draw list item.
public delegate T ItemDrawer<T>( Rect position, T item )
Generic Template Parameters
- T
- Type of item list.
Parameters
- position (Rect)
- Position of list item.
- item (T)
- The list item.
Return Value
The modified value.Remarks
GUI controls must be positioned absolutely within the given rectangle since list items must be sized consistently.
Examples
The following listing presents a text field for each list item:
C#
UnityScript
CopyC#
using UnityEngine; using UnityEditor; using System.Collections.Generic; public class ExampleWindow : EditorWindow { public List<string> wishlist = new List<string>(); private void OnGUI() { ReorderableListGUI.ListField(wishlist, DrawListItem); } private string DrawListItem(Rect position, string value) { // Text fields do not like `null` values! if (value == null) value = ""; return EditorGUI.TextField(position, value); } }
CopyUnityScript
import System.Collections.Generic; class ExampleWindow extends EditorWindow { var wishlist:List.<String>; function OnGUI() { ReorderableListGUI.ListField(wishlist, DrawListItem); } function DrawListItem(position:Rect, value:String):String { // Text fields do not like `null` values! if (value == null) value = ''; return EditorGUI.TextField(position, value); } }