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"),
                truetruetruetrue);
 
        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;


'Unity > Editor' 카테고리의 다른 글

Editor코드로 Button에 OnClick 리스너 설정하기  (0) 2018.12.06
ScriptableObject  (0) 2018.11.29
Unity 실행 시 에디터 스크립트 코드 실행  (0) 2018.11.21
트리뷰(TreeView)  (0) 2018.11.21
커스텀 에디터(CustomEditor)  (0) 2018.11.21

+ Recent posts