RoutesEditor.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using UnityEditor;
  2. using UnityEngine;
  3. [CustomEditor(typeof(Routes.Routes))]
  4. [CanEditMultipleObjects]
  5. // ReSharper disable once CheckNamespace
  6. public class RoutesEditor : Editor
  7. {
  8. private bool showListContent;
  9. public override void OnInspectorGUI()
  10. {
  11. serializedObject.Update();
  12. RoutesList(serializedObject.FindProperty("routes"));
  13. //EditorGUILayout.PropertyField(routes.FindPropertyRelative("arraySize"), true);
  14. EditorGUILayout.Space();
  15. EditorGUILayout.PropertyField(serializedObject.FindProperty("selectedRoute"), true);
  16. serializedObject.ApplyModifiedProperties();
  17. }
  18. private void RoutesList(SerializedProperty list)
  19. {
  20. showListContent = EditorGUILayout.BeginFoldoutHeaderGroup(showListContent, $"{list.displayName} (Length = {list.arraySize})");
  21. if (showListContent)
  22. {
  23. EditorGUI.indentLevel += 1;
  24. EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
  25. for (var i = 0; i < list.arraySize; i++) {
  26. RouteDrawer.PropertyField(list.GetArrayElementAtIndex(i));
  27. }
  28. EditorGUI.indentLevel -= 1;
  29. }
  30. EditorGUILayout.EndFoldoutHeaderGroup();
  31. }
  32. }