ReorderableList是可以通過手動拖拽更改列表順序凄敢,例子如下:
using UnityEditorInternal;
using UnityEditor;
using System.Collections.Generic;
public class ReorderableListTest : EditorWindow {
private ReorderableList _list;
//應(yīng)該用持久化數(shù)據(jù)玖详,案例暫時用這個
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);根據(jù)rect調(diào)整位置
}
}