From 760c789acbd363bd2d7150f41d89f6be51e879fe Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Fri, 9 May 2025 23:41:33 +0800 Subject: [PATCH] Update RuntimeComponentsDrawer.cs --- .../Editor/RuntimeComponentsDrawer.cs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Internal/Editor/RuntimeComponentsDrawer.cs b/src/Internal/Editor/RuntimeComponentsDrawer.cs index 8a2e318..ff2aa57 100644 --- a/src/Internal/Editor/RuntimeComponentsDrawer.cs +++ b/src/Internal/Editor/RuntimeComponentsDrawer.cs @@ -66,6 +66,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X public readonly bool IsUnityObjectType; public readonly bool IsUnitySerializable; + public readonly bool IsCompositeType; public readonly bool IsUnmanaged; public readonly FieldInfoData[] Fields; @@ -90,7 +91,12 @@ namespace DCFApixels.DragonECS.Unity.Editors.X //type.IsPrimitive || //type == typeof(string) || //type.IsEnum || - (!type.IsGenericType && type.IsSerializable && type.HasAttribute()); + (!type.IsGenericType && type.HasAttribute() && type.IsArray == false); + + IsCompositeType = + type.IsPrimitive == false && + type.IsArray == false && + type != typeof(string); if (type == typeof(void)) { return; } @@ -379,9 +385,12 @@ namespace DCFApixels.DragonECS.Unity.Editors.X bool changed = false; - if (cache.IsUnitySerializable == false) + if (cache.IsUnitySerializable == false && cache.IsCompositeType) { - isExpanded = EditorGUILayout.BeginFoldoutHeaderGroup(isExpanded, label, EditorStyles.foldout); + var foldoutStyle = EditorStyles.foldout; + Rect rect = GUILayoutUtility.GetRect(label, foldoutStyle); + rect.xMin += EcsGUI.Indent; + isExpanded = EditorGUI.BeginFoldoutHeaderGroup(rect, isExpanded, label, foldoutStyle, null, null); EditorGUILayout.EndFoldoutHeaderGroup(); if (isExpanded) @@ -401,8 +410,8 @@ namespace DCFApixels.DragonECS.Unity.Editors.X } } } - } + } } else @@ -437,22 +446,21 @@ namespace DCFApixels.DragonECS.Unity.Editors.X else { EditorGUI.BeginChangeCheck(); - RefEditorWrapper wrapper = cache.GetWrapper(_runtimeComponentsDepth); - wrapper.data = data; - wrapper.SO.Update(); - wrapper.IsExpanded = isExpanded; try { - if (fieldInfoData.IsPassToUnitySerialize) + if (cache.IsCompositeType && fieldInfoData.IsPassToUnitySerialize) { + wrapper.SO.Update(); + wrapper.IsExpanded = isExpanded; EditorGUILayout.PropertyField(wrapper.Property, label, true); } else { - EditorGUILayout.LabelField(label, " "); + //EcsGUI. + EditorGUILayout.LabelField(label); } } catch (ArgumentException)