1234567891011121314151617181920212223242526272829303132333435363738 |
- using UnityEditor;
- using UnityEngine;
- [CustomEditor(typeof(Routes.Routes))]
- [CanEditMultipleObjects]
- // ReSharper disable once CheckNamespace
- public class RoutesEditor : Editor
- {
- private bool showListContent;
-
- public override void OnInspectorGUI()
- {
- serializedObject.Update();
- RoutesList(serializedObject.FindProperty("routes"));
- //EditorGUILayout.PropertyField(routes.FindPropertyRelative("arraySize"), true);
- EditorGUILayout.Space();
- EditorGUILayout.PropertyField(serializedObject.FindProperty("selectedRoute"), true);
- serializedObject.ApplyModifiedProperties();
- }
- private void RoutesList(SerializedProperty list)
- {
- showListContent = EditorGUILayout.BeginFoldoutHeaderGroup(showListContent, $"{list.displayName} (Length = {list.arraySize})");
- if (showListContent)
- {
- EditorGUI.indentLevel += 1;
- EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
- for (var i = 0; i < list.arraySize; i++) {
- RouteDrawer.PropertyField(list.GetArrayElementAtIndex(i));
- }
- EditorGUI.indentLevel -= 1;
- }
-
- EditorGUILayout.EndFoldoutHeaderGroup();
-
- }
- }
|