12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using Routes;
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.UIElements;
- // ReSharper disable once CheckNamespace
- public static class RouteDrawer
- {
- private static bool showListContent = true;
- public static void PropertyField(SerializedProperty route)
- {
- Debug.Log("route = "+route);
- ListField(route.FindPropertyRelative("items"));
- }
- private static void ListField(SerializedProperty list)
- {
- //EditorGUILayout.BeginHorizontal();
- showListContent = EditorGUILayout.Foldout(showListContent, $"{list.displayName} (Length = {0/*list.arraySize*/})");
- EditorGUILayout.EndHorizontal();
- //EditorGUILayout.PropertyField(list.displayName);
- if (showListContent) {
- EditorGUI.indentLevel += 1;
- for (var i = 0; i < list.arraySize; i++) {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));
- if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(32)))
- {
- list.DeleteArrayElementAtIndex(i);
- }
- EditorGUILayout.EndHorizontal();
- }
- EditorGUI.indentLevel -= 1;
- }
-
- //EditorGUILayout.EndHorizontal();
- //EditorGUILayout.EndFoldoutHeaderGroup();
- /*if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(128)))
- {
- list.InsertArrayElementAtIndex(0);
- }*/
- }
- }
|