From 1176853cd5fe699ccb37412f029ee52964792e45 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 4 Mar 2024 08:21:01 +0800 Subject: [PATCH] upddate --- .../EcsDefaultWorldSingletonProvider.cs | 2 +- src/Connectors/AutoEntityCreator.cs | 1 + src/Connectors/EcsEntityConnect.cs | 2 +- src/Debug/Editor/DebugMonitorPrefs.cs | 24 ++++++++++++-- src/Editor/EditorUtility.cs | 33 ++++++++++++------- 5 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/Buildin/EcsDefaultWorldSingletonProvider.cs b/src/Buildin/EcsDefaultWorldSingletonProvider.cs index 956c326..c05aecc 100644 --- a/src/Buildin/EcsDefaultWorldSingletonProvider.cs +++ b/src/Buildin/EcsDefaultWorldSingletonProvider.cs @@ -9,7 +9,7 @@ { if (_instance == null) { - _instance = FindOrCreateSingleton("DefaultSingletonProvider"); + _instance = FindOrCreateSingleton("SingletonDefaultWorld"); } return _instance; } diff --git a/src/Connectors/AutoEntityCreator.cs b/src/Connectors/AutoEntityCreator.cs index 773360f..14ae2d7 100644 --- a/src/Connectors/AutoEntityCreator.cs +++ b/src/Connectors/AutoEntityCreator.cs @@ -65,6 +65,7 @@ namespace DCFApixels.DragonECS internal void Autoset_Editor() { _connect = GetComponentInChildren(); + AutoResolveWorldProviderDependensy(); } #endif } diff --git a/src/Connectors/EcsEntityConnect.cs b/src/Connectors/EcsEntityConnect.cs index de9aa1f..1e66505 100644 --- a/src/Connectors/EcsEntityConnect.cs +++ b/src/Connectors/EcsEntityConnect.cs @@ -224,7 +224,7 @@ namespace DCFApixels.DragonECS.Unity.Editors } if (Target.Entity.TryUnpack(out int entityID, out EcsWorld world)) { - EcsGUI.Layout.DrawComponents(entityID, world); + EcsGUI.Layout.DrawRuntimeComponents(entityID, world); } } } diff --git a/src/Debug/Editor/DebugMonitorPrefs.cs b/src/Debug/Editor/DebugMonitorPrefs.cs index b6385e7..5b2e722 100644 --- a/src/Debug/Editor/DebugMonitorPrefs.cs +++ b/src/Debug/Editor/DebugMonitorPrefs.cs @@ -1,4 +1,5 @@ #if UNITY_EDITOR +using UnityEngine; using UnityEditor; namespace DCFApixels.DragonECS.Unity.Editors @@ -6,29 +7,46 @@ namespace DCFApixels.DragonECS.Unity.Editors [FilePath(EcsConsts.FRAMEWORK_NAME + "/" + nameof(DebugMonitorPrefs) + ".prefs", FilePathAttribute.Location.ProjectFolder)] public class DebugMonitorPrefs : ScriptableSingleton { + [SerializeField] private bool _isShowInterfaces = false; public bool IsShowInterfaces { - get => _isShowInterfaces; set + get => _isShowInterfaces; + set { _isShowInterfaces = value; Save(false); } } + [SerializeField] private bool _isShowHidden = false; public bool IsShowHidden { - get => _isShowHidden; set + get => _isShowHidden; + set { _isShowHidden = value; Save(false); } } + [SerializeField] + private bool _isShowRuntimeComponents = true; + public bool IsShowRuntimeComponents + { + get => _isShowRuntimeComponents; + set + { + _isShowRuntimeComponents = value; + Save(false); + } + } + [SerializeField] private bool _poolsToggle = false; public bool PoolsToggle { - get => _poolsToggle; set + get => _poolsToggle; + set { _poolsToggle = value; Save(false); diff --git a/src/Editor/EditorUtility.cs b/src/Editor/EditorUtility.cs index 3f02756..f17bc5b 100644 --- a/src/Editor/EditorUtility.cs +++ b/src/Editor/EditorUtility.cs @@ -84,32 +84,41 @@ namespace DCFApixels.DragonECS.Unity.Editors get { return DebugMonitorPrefs.instance.IsShowHidden; } set { DebugMonitorPrefs.instance.IsShowHidden = value; } } - public static void DrawComponents(entlong entity) + private static bool IsShowRuntimeComponents + { + get { return DebugMonitorPrefs.instance.IsShowRuntimeComponents; } + set { DebugMonitorPrefs.instance.IsShowRuntimeComponents = value; } + } + public static void DrawRuntimeComponents(entlong entity) { if (entity.TryUnpack(out int entityID, out EcsWorld world)) { - DrawComponents(entityID, world); + DrawRuntimeComponents(entityID, world); } } - public static void DrawComponents(int entityID, EcsWorld world) + public static void DrawRuntimeComponents(int entityID, EcsWorld world) { var componentTypeIDs = world.GetComponentTypeIDs(entityID); GUILayout.BeginVertical(EcsEditor.GetStyle(Color.black, 0.2f)); - GUILayout.Label("COMPONENTS"); - IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden); - foreach (var componentTypeID in componentTypeIDs) + IsShowRuntimeComponents = EditorGUILayout.Foldout(IsShowRuntimeComponents, "RUNTIME COMPONENTS"); + if (IsShowRuntimeComponents) { - var pool = world.GetPool(componentTypeID); + //TODO галочкаслишком чернаяя, невидно + IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHiddens); + foreach (var componentTypeID in componentTypeIDs) { - DrawComponent(entityID, pool); + var pool = world.GetPool(componentTypeID); + { + DrawRuntimeComponent(entityID, pool); + } } } GUILayout.EndVertical(); } private static readonly BindingFlags fieldFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; - private static void DrawComponent(int entityID, IEcsPool pool) + private static void DrawRuntimeComponent(int entityID, IEcsPool pool) { var meta = pool.ComponentType.ToMeta(); if (meta.IsHidden == false || IsShowHidden) @@ -121,7 +130,7 @@ namespace DCFApixels.DragonECS.Unity.Editors Type componentType = pool.ComponentType; ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType); - bool changed = DrawData(componentType, new GUIContent(meta.Name), expandMatrix, data, out object resultData); + bool changed = DrawRuntimeData(componentType, new GUIContent(meta.Name), expandMatrix, data, out object resultData); if (changed) { pool.SetRaw(entityID, resultData); @@ -132,7 +141,7 @@ namespace DCFApixels.DragonECS.Unity.Editors } } - private static bool DrawData(Type fieldType, GUIContent label, ExpandMatrix expandMatrix, object data, out object outData) + private static bool DrawRuntimeData(Type fieldType, GUIContent label, ExpandMatrix expandMatrix, object data, out object outData) { Type type = data.GetType(); UnityEngine.Object uobj = data as UnityEngine.Object; @@ -150,7 +159,7 @@ namespace DCFApixels.DragonECS.Unity.Editors foreach (var field in type.GetFields(fieldFlags)) { GUIContent subLabel = new GUIContent(EcsUnityEditorUtility.TransformFieldName(field.Name)); - if (DrawData(field.FieldType, subLabel, expandMatrix, field.GetValue(data), out object fieldData)) + if (DrawRuntimeData(field.FieldType, subLabel, expandMatrix, field.GetValue(data), out object fieldData)) { field.SetValue(data, fieldData);