From e2286a877ea93953c8fb63d46a617ff8280c9aad Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:29:27 +0800 Subject: [PATCH] refactoring / fixes --- src/Consts.cs | 12 +++--- src/Internal/Editor/EcsGUI.cs | 40 +++++++++---------- src/Internal/Editor/MetaObjectsDropDown.cs | 2 +- .../Templates/ScriptableEntityTemplate.cs | 7 ---- 4 files changed, 27 insertions(+), 34 deletions(-) diff --git a/src/Consts.cs b/src/Consts.cs index 14d9975..67b41c2 100644 --- a/src/Consts.cs +++ b/src/Consts.cs @@ -18,11 +18,11 @@ public class EcsUnityDefines { - public const bool DISABLE_SERIALIZE_REFERENCE_RECOVERY = -#if DISABLE_SERIALIZE_REFERENCE_RECOVERY - true; -#else - false; -#endif + // public const bool DISABLE_SERIALIZE_REFERENCE_RECOVERY = + //#if DISABLE_SERIALIZE_REFERENCE_RECOVERY + // true; + //#else + // false; + //#endif } } diff --git a/src/Internal/Editor/EcsGUI.cs b/src/Internal/Editor/EcsGUI.cs index 53b114d..55f5880 100644 --- a/src/Internal/Editor/EcsGUI.cs +++ b/src/Internal/Editor/EcsGUI.cs @@ -597,7 +597,7 @@ namespace DCFApixels.DragonECS.Unity.Editors optionButton.yMin = optionButton.yMax; optionButton.yMax += HeadIconsRect.height; optionButton.xMin = optionButton.xMax - 64; - optionButton.center += Vector2.up * DrawTypeMetaBlockPadding * 1f; + optionButton.center += Vector2.up * DrawTypeMetaBlockPadding; //Canceling isExpanded bool oldIsExpanded = rootProperty.isExpanded; @@ -1083,33 +1083,33 @@ namespace DCFApixels.DragonECS.Unity.Editors { var componentTypeIDs = world.GetComponentTypeIDsFor(entityID); - GUILayout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f)); - - if (isWithFoldout) + using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f))) { - IsShowRuntimeComponents = EditorGUILayout.BeginFoldoutHeaderGroup(IsShowRuntimeComponents, "RUNTIME COMPONENTS", EditorStyles.foldout); - EditorGUILayout.EndFoldoutHeaderGroup(); - } - if (isWithFoldout == false || IsShowRuntimeComponents) - { - if (AddComponentButtons(out Rect dropDownRect)) + if (isWithFoldout) { - RuntimeComponentsUtility.GetAddComponentGenericMenu(world).Open(dropDownRect, entityID); + IsShowRuntimeComponents = EditorGUILayout.BeginFoldoutHeaderGroup(IsShowRuntimeComponents, "RUNTIME COMPONENTS", EditorStyles.foldout); + EditorGUILayout.EndFoldoutHeaderGroup(); } - - GUILayout.Box("", UnityEditorUtility.GetStyle(GUI.color, 0.16f), GUILayout.ExpandWidth(true)); - IsShowHidden = EditorGUI.Toggle(GUILayoutUtility.GetLastRect(), "Show Hidden", IsShowHidden); - - int i = 0; - foreach (var componentTypeID in componentTypeIDs) + if (isWithFoldout == false || IsShowRuntimeComponents) { - var pool = world.FindPoolInstance(componentTypeID); + if (AddComponentButtons(out Rect dropDownRect)) { - DrawRuntimeComponent(componentTypeIDs.Length, i++, entityID, pool); + RuntimeComponentsUtility.GetAddComponentGenericMenu(world).Open(dropDownRect, entityID); + } + + GUILayout.Box("", UnityEditorUtility.GetStyle(GUI.color, 0.16f), GUILayout.ExpandWidth(true)); + IsShowHidden = EditorGUI.Toggle(GUILayoutUtility.GetLastRect(), "Show Hidden", IsShowHidden); + + int i = 0; + foreach (var componentTypeID in componentTypeIDs) + { + var pool = world.FindPoolInstance(componentTypeID); + { + DrawRuntimeComponent(componentTypeIDs.Length, i++, entityID, pool); + } } } } - GUILayout.EndVertical(); } private static void DrawRuntimeComponent(int total, int index, int entityID, IEcsPool pool) { diff --git a/src/Internal/Editor/MetaObjectsDropDown.cs b/src/Internal/Editor/MetaObjectsDropDown.cs index ac391d2..2d6c99b 100644 --- a/src/Internal/Editor/MetaObjectsDropDown.cs +++ b/src/Internal/Editor/MetaObjectsDropDown.cs @@ -161,7 +161,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { IEnumerable<(IEcsPool, ITypeMeta)> itemMetaPairs = pools.Select(pool => { - return (pool, (ITypeMeta)pool.ComponentType.GetMeta()); + return (pool, (ITypeMeta)pool.ComponentType.ToMeta()); }); Setup(itemMetaPairs); } diff --git a/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs b/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs index 4e89a40..042471c 100644 --- a/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs +++ b/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs @@ -1,20 +1,13 @@ using DCFApixels.DragonECS.Unity; using DCFApixels.DragonECS.Unity.Internal; using System; -using System.Collections.Generic; using UnityEngine; namespace DCFApixels.DragonECS { public abstract class ScriptableEntityTemplateBase : ScriptableObject, ITemplate { - [SerializeField] - private int _saveID; public abstract void Apply(short worldID, int entityID); - - private static IComponentTemplate _fake = null; - protected virtual IList GetToRecover() { return null; } - protected virtual ref IComponentTemplate GetToRecoverSingle() { return ref _fake; } } [MetaColor(MetaColor.Cyan)]