Delegate ReorderableListControl.ItemDrawer<T>
Invoked to draw list item.
Namespace: Unity.VisualScripting.ReorderableList
Syntax
public delegate T ItemDrawer<T>(Rect position, T item);
Parameters
Type | Name | Description |
---|---|---|
Rect | position | Position of list item. |
T | item | The list item. |
Returns
Type | Description |
---|---|
T | The modified value. |
Type Parameters
Name | Description |
---|---|
T | Type of item list. |
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:
using Unity.VisualScripting.Dependencies.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);
}
}