Reorderable List Control for Unity
| ReorderableListControlItemDrawerT Delegate |
Invoked to draw list item.
Namespace: Rotorz.ReorderableList
Assembly: Editor.ReorderableList (in Editor.ReorderableList.dll) Version: 0.0.0.0 (0.3.0.0)
Syntaxpublic delegate T ItemDrawer<T>( Rect position, T item )
public delegate ItemDrawer.<T>( position : Rect, item : T ) : T
Parameters
- position
- Type: Rect
Position of list item. - item
- Type: T
The list item.
Type Parameters
- T
- Type of item list.
Return Value
Type: TThe modified value.
RemarksGUI controls must be positioned absolutely within the given rectangle since list items must be sized consistently.
ExamplesThe following listing presents a text field for each list item:
using Rotorz.ReorderableList; using System.Collections.Generic; using UnityEditor; using UnityEngine; 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); } }
import Rotorz.ReorderableList;
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);
}
}
See Also