diff --git a/src/Connectors/EcsWorldProvider.cs b/src/Connectors/EcsWorldProvider.cs index c9623a8..0f711f8 100644 --- a/src/Connectors/EcsWorldProvider.cs +++ b/src/Connectors/EcsWorldProvider.cs @@ -123,7 +123,7 @@ namespace DCFApixels.DragonECS { EcsWorldConfig config = new EcsWorldConfig(_entitiesCapacity, _groupCapacity, _poolsCapacity, _poolComponentsCapacity, _poolRecycledComponentsCapacity); ConfigContainer configs = new ConfigContainer().Set(config); - return (TWorld)Activator.CreateInstance(typeof(TWorld), new object[] { configs, _worldID }); + return (TWorld)Activator.CreateInstance(typeof(TWorld), new object[] { configs, null, _worldID }); } protected virtual void OnWorldCreated(TWorld world) { } #endregion diff --git a/src/Connectors/Editor/EcsWorldProviderBaseEditor.cs b/src/Connectors/Editor/EcsWorldProviderBaseEditor.cs index 2d8a12b..8d61c90 100644 --- a/src/Connectors/Editor/EcsWorldProviderBaseEditor.cs +++ b/src/Connectors/Editor/EcsWorldProviderBaseEditor.cs @@ -33,7 +33,6 @@ namespace DCFApixels.DragonECS.Unity.Editors } EcsGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw()); - base.OnInspectorGUI(); GUILayout.Space(10); @@ -53,6 +52,8 @@ namespace DCFApixels.DragonECS.Unity.Editors c.a = 0.3f; EditorGUI.DrawRect(r, c); GUILayout.Space(10); + + EcsGUI.Layout.DrawWorldComponents(Target.GetCurrentWorldRaw()); } } } diff --git a/src/DebugUtils/Monitors/Editor/WorldMonitorEditor.cs b/src/DebugUtils/Monitors/Editor/WorldMonitorEditor.cs index 67149d2..ea734fc 100644 --- a/src/DebugUtils/Monitors/Editor/WorldMonitorEditor.cs +++ b/src/DebugUtils/Monitors/Editor/WorldMonitorEditor.cs @@ -118,6 +118,8 @@ namespace DCFApixels.DragonECS.Unity.Editors EcsGUI.Layout.DrawWorldBaseInfo(Target.World); + + EcsGUI.Layout.DrawWorldComponents(Target.World); } } } diff --git a/src/Internal/Editor/EcsGUI.cs b/src/Internal/Editor/EcsGUI.cs index 39f84c2..9649305 100644 --- a/src/Internal/Editor/EcsGUI.cs +++ b/src/Internal/Editor/EcsGUI.cs @@ -453,18 +453,6 @@ namespace DCFApixels.DragonECS.Unity.Editors } #endregion - //#region One line elems - //public static bool LeftToggle(Rect position, GUIContent label, bool value) - //{ - // position = position.AddPadding(indent, 0, 0, 0); - // Rect togglePos; - // (togglePos, position) = position.HorizontalSliceLeft(18f); - // - // EditorGUI.togg(position, label); - // GUI.Label(position, label); - //} - //#endregion - #region entity bar public static void EntityBarForAlive(Rect position, EntityStatus status, int id, short gen, short world) { @@ -1088,16 +1076,92 @@ namespace DCFApixels.DragonECS.Unity.Editors bool isNull = world == null || world.IsDestroyed || world.ID == 0; int entitesCount = isNull ? 0 : world.Count; int capacity = isNull ? 0 : world.Capacity; + long Version = isNull ? 0 : world.Version; int leakedEntitesCount = isNull ? 0 : world.CountLeakedEntitesDebug(); EditorGUILayout.IntField("Entities", entitesCount, EditorStyles.boldLabel); EditorGUILayout.IntField("Capacity", capacity, EditorStyles.boldLabel); - EditorGUILayout.LongField("Version", world.Version, EditorStyles.boldLabel); + EditorGUILayout.LongField("Version", Version, EditorStyles.boldLabel); Color color = leakedEntitesCount > 0 ? Color.yellow : GUI.contentColor; using (new ContentColorScope(color)) { EditorGUILayout.IntField("Leaked Entites", leakedEntitesCount, EditorStyles.boldLabel); } } + public static void DrawWorldComponents(EcsWorld world) + { + bool isNull = world == null || world.IsDestroyed || world.ID == 0; + if (isNull) { return; } + using (BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f))) + { + IsShowRuntimeComponents = EditorGUILayout.BeginFoldoutHeaderGroup(IsShowRuntimeComponents, "RUNTIME COMPONENTS", EditorStyles.foldout); + EditorGUILayout.EndFoldoutHeaderGroup(); + if (IsShowRuntimeComponents == false) { return; } + + var worldID = world.ID; + var cmps = world.GetWorldComponents(); + int index = -1; + int total = 9; + foreach (var cmp in cmps) + { + index++; + var meta = cmp.ComponentType.ToMeta(); + if (meta.IsHidden == false || IsShowHidden) + { + Type componentType = cmp.ComponentType; + + object data = cmp.GetRaw(worldID); + + ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType); + + float padding = EditorGUIUtility.standardVerticalSpacing; + Rect optionButton = GUILayoutUtility.GetLastRect(); + optionButton.yMin = optionButton.yMax; + optionButton.yMax += HeadIconsRect.height; + optionButton.xMin = optionButton.xMax - 64; + optionButton.center += Vector2.up * padding * 2f; + //Canceling isExpanded + if (ClickTest(optionButton)) + { + ref bool isExpanded = ref expandMatrix.Down(); + isExpanded = !isExpanded; + } + + Color panelColor = SelectPanelColor(meta, index, total); + GUILayout.BeginVertical(UnityEditorUtility.GetStyle(panelColor, EscEditorConsts.COMPONENT_DRAWER_ALPHA)); + EditorGUI.BeginChangeCheck(); + + ////Close button + //optionButton.xMin = optionButton.xMax - HeadIconsRect.width; + //if (CloseButton(optionButton)) + //{ + // cmp.Del(worldID); + // return; + //} + + //Edit script button + if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script)) + { + optionButton = HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); + EcsGUI.ScriptAssetButton(optionButton, script); + } + //Description icon + if (string.IsNullOrEmpty(meta.Description.Text) == false) + { + optionButton = HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); + DescriptionIcon(optionButton, meta.Description.Text); + } + + RuntimeComponentReflectionCache.FieldInfoData componentInfoData = new RuntimeComponentReflectionCache.FieldInfoData(null, componentType, meta.Name); + if (DrawRuntimeData(ref componentInfoData, UnityEditorUtility.GetLabel(meta.Name), expandMatrix, data, out object resultData)) + { + cmp.SetRaw(worldID, resultData); + } + + GUILayout.EndVertical(); + } + } + } + } #region entity bar public static void EntityBarForAlive(EntityStatus status, int id, short gen, short world)