ReorderableList是可以通过手动拖拽更改列表顺序,例子如下:
using UnityEditorInternal;
using UnityEditor;
using System.Collections.Generic;
public class ReorderableListTest : EditorWindow {
private ReorderableList _list;
//应该用持久化数据,案例暂时用这个
private List<string> _data = new List<string>();
public ReorderableListTest()
{
_list = new ReorderableList(_data, _data.GetType());
_list.drawElementCallback = (rect, index, isActive, isFocused) =>
{
EditorGUI.TextField(rect,_data[index]);
};
_list.onAddCallback = (list) =>
{
_data.Add("");
};
}
private void OnGUI()
{
_list.DoLayoutList();
//_list.DoList(rect);根据rect调整位置
}
}