using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; #if UNITY_EDITOR using UnityEditor; using UnityEditorInternal; #endif #if UNITY_EDITOR namespace VketCloudGUITools.Editor { public class VCStateToggleReordableList { private ReorderableList _reorderableList; private SerializedObject _serializedObject; public void RefleshReordableList(SerializedObject serializedObject, SerializedProperty elementsProperty) { _serializedObject = serializedObject; _reorderableList = new ReorderableList(serializedObject, elementsProperty); _reorderableList.drawElementCallback += (Rect rect, int index, bool selected, bool focused) => { SerializedProperty property = _reorderableList.serializedProperty.GetArrayElementAtIndex(index); EditorGUI.PropertyField(rect, property, GUIContent.none); }; _reorderableList.drawHeaderCallback += rect => { EditorGUI.LabelField(rect, elementsProperty.displayName); }; } public void OnInspectorGUI(SerializedObject serializedObject, SerializedProperty property) { if (_serializedObject != serializedObject) RefleshReordableList(serializedObject, property); if (_reorderableList != null) _reorderableList.DoLayoutList(); } } } #endif