Unity/Editor
ReorderableList
잉여씨
2018. 11. 29. 10:48
ReorderableList
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | using UnityEditor; using UnityEditorInternal; using UnityEngine; public class ReorderableListTemplete : Editor { private ReorderableList list; private void OnEnable() { list = new ReorderableList(serializedObject, serializedObject.FindProperty("Waves"), true, true, true, true); list.drawElementCallback = DrawElementCallback; } void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused) { var element = list.serializedProperty.GetArrayElementAtIndex(index); rect.y += 2; EditorGUI.PropertyField( new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Type"), GUIContent.none); EditorGUI.PropertyField( new Rect(rect.x + 60, rect.y, rect.width - 60 - 30, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Prefab"), GUIContent.none); EditorGUI.PropertyField( new Rect(rect.x + rect.width - 30, rect.y, 30, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Count"), GUIContent.none); } public override void OnInspectorGUI() { serializedObject.Update(); list.DoLayoutList(); serializedObject.ApplyModifiedProperties(); } } | cs |
생성자
public ReorderableList(IList elements, Type elementType);
public ReorderableList(SerializedObject serializedObject, SerializedProperty elements);
public ReorderableList(IList elements, Type elementType, bool draggable, bool displayHeader, bool displayAddButton, bool displayRemoveButton);
public ReorderableList(SerializedObject serializedObject, SerializedProperty elements, bool draggable, bool displayHeader, bool displayAddButton, bool displayRemoveButton);
콜백함수
onCanAddCallback;
onCanRemoveCallback;
onMouseUpCallback;
onRemoveCallback;
onChangedCallback;
onAddCallback;
onAddDropdownCallback;
drawElementCallback;
drawElementBackgroundCallback;
drawNoneElementCallback;
drawFooterCallback;
onReorderCallbackWithDetails;
onReorderCallback;
onSelectCallback;
elementHeightCallback;