diff --git a/src/Internal/Editor/EcsGUI.cs b/src/Internal/Editor/EcsGUI.cs index 37b92cb..e4d4e17 100644 --- a/src/Internal/Editor/EcsGUI.cs +++ b/src/Internal/Editor/EcsGUI.cs @@ -705,7 +705,7 @@ namespace DCFApixels.DragonECS.Unity.Editors #region Other Elements public static bool AddComponentButton(Rect position, out Rect dropDownRect) { - dropDownRect = RectUtility.AddPadding(position, 20f, 20f, 12f, 2f); + dropDownRect = RectUtility.AddPadding(position, 20f, 20f, 1f, 1f); ; return GUI.Button(dropDownRect, "Add Component"); } public static AddClearButton AddClearComponentButtons(Rect position, out Rect dropDownRect) @@ -718,7 +718,7 @@ namespace DCFApixels.DragonECS.Unity.Editors } public static AddClearButton AddClearButtons(Rect position, string addText, string clearText, out Rect dropDownRect) { - position = RectUtility.AddPadding(position, 20f, 20f, 12f, 2f); + position = RectUtility.AddPadding(position, 20f, 20f, 1f, 1f); var (left, right) = RectUtility.HorizontalSliceLerp(position, 0.75f); dropDownRect = left; @@ -1080,15 +1080,15 @@ namespace DCFApixels.DragonECS.Unity.Editors public static bool AddComponentButtons(out Rect dropDownRect) { - return EcsGUI.AddComponentButton(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 36f), out dropDownRect); + return EcsGUI.AddComponentButton(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect); } public static AddClearButton AddClearComponentButtons(out Rect dropDownRect) { - return EcsGUI.AddClearComponentButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 36f), out dropDownRect); + return EcsGUI.AddClearComponentButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect); } public static AddClearButton AddClearSystemButtons(out Rect dropDownRect) { - return EcsGUI.AddClearSystemButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 36f), out dropDownRect); + return EcsGUI.AddClearSystemButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect); } public static void DrawRuntimeComponents(entlong entity, bool isWithFoldout = true) { diff --git a/src/Internal/Editor/MetaObjectsDropDown.cs b/src/Internal/Editor/MetaObjectsDropDown.cs index 2d6c99b..3cf76fb 100644 --- a/src/Internal/Editor/MetaObjectsDropDown.cs +++ b/src/Internal/Editor/MetaObjectsDropDown.cs @@ -198,7 +198,7 @@ namespace DCFApixels.DragonECS.Unity.Editors private IEnumerable<(T, ITypeMeta)> _itemMetaPairs; public MetaObjectsDropDown() : base(new AdvancedDropdownState()) { - minimumSize = new Vector2(minimumSize.x, EditorGUIUtility.singleLineHeight * 30); + minimumSize = new Vector2(220f, EditorGUIUtility.singleLineHeight * 20); } protected void Setup(IEnumerable<(T, ITypeMeta)> itemMetaPairs, string name = "Select Type...", bool isContainsNull = true) diff --git a/src/Templates/EcsPipelineTemplate/Editor/EcsPipelineTemplateSOEditor.cs b/src/Templates/EcsPipelineTemplate/Editor/EcsPipelineTemplateSOEditor.cs index 890ade1..116aa3f 100644 --- a/src/Templates/EcsPipelineTemplate/Editor/EcsPipelineTemplateSOEditor.cs +++ b/src/Templates/EcsPipelineTemplate/Editor/EcsPipelineTemplateSOEditor.cs @@ -228,6 +228,8 @@ namespace DCFApixels.DragonECS.Unity.Editors GUILayout.Label(UnityEditorUtility.GetLabel(recordsProp.displayName), EditorStyles.boldLabel); using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f))) { + GUILayout.Space(4f); + switch (EcsGUI.Layout.AddClearSystemButtons(out Rect dropDownRect)) { case EcsGUI.AddClearButton.Add: diff --git a/src/Templates/EntityTemplate/Editor/EntityTemplateEditor.cs b/src/Templates/EntityTemplate/Editor/EntityTemplateEditor.cs index fd5792c..3e6d452 100644 --- a/src/Templates/EntityTemplate/Editor/EntityTemplateEditor.cs +++ b/src/Templates/EntityTemplate/Editor/EntityTemplateEditor.cs @@ -1,7 +1,6 @@ #if UNITY_EDITOR using DCFApixels.DragonECS.Unity.Internal; using DCFApixels.DragonECS.Unity.RefRepairer.Editors; -using System; using UnityEditor; using UnityEditorInternal; using UnityEngine; @@ -58,28 +57,14 @@ namespace DCFApixels.DragonECS.Unity.Editors } SerializedProperty componentProperty = prop; - try + if (componentProperty.managedReferenceValue is ComponentTemplateBase customTemplate) { - if (componentProperty.managedReferenceValue is ComponentTemplateBase customTemplate) - { - componentProperty = prop.FindPropertyRelative("component"); - } - - if (componentProperty == null) - { - //Debug.Log(prop.displayName); - throw new NullReferenceException(); - } - } - catch (Exception e) - { - Debug.LogException(e, serializedObject.targetObject); - //DrawDamagedComponent(index, "Damaged component template."); - return prop; + componentProperty = prop.FindPropertyRelative("component"); } - return componentProperty; + return componentProperty == null ? prop : componentProperty; } + private float OnReorderableComponentsListElementHeight(int index) { var componentProperty = GetTargetProperty(_componentsProp.GetArrayElementAtIndex(index)); @@ -194,11 +179,12 @@ namespace DCFApixels.DragonECS.Unity.Editors { DrawTop(Target, _componentsProp); _reorderableComponentsList.DoLayoutList(); - } } private void DrawTop(ITemplateInternal target, SerializedProperty componentsProp) { + GUILayout.Space(2f); + switch (EcsGUI.Layout.AddClearComponentButtons(out Rect rect)) { case EcsGUI.AddClearButton.Add: diff --git a/src/Templates/EntityTemplate/Templates/ComponentTemplateBase.cs b/src/Templates/EntityTemplate/Templates/ComponentTemplateBase.cs index c1cb9e0..248f24a 100644 --- a/src/Templates/EntityTemplate/Templates/ComponentTemplateBase.cs +++ b/src/Templates/EntityTemplate/Templates/ComponentTemplateBase.cs @@ -61,6 +61,7 @@ namespace DCFApixels.DragonECS [SerializeField] protected T component; [SerializeField] + [HideInInspector] private byte _offset; // Fucking Unity drove me crazy with the error "Cannot get managed reference index with out bounds offset". This workaround helps avoid that error. #region Properties diff --git a/src/Templates/EntityTemplate/Templates/MonoEntityTemplate.cs b/src/Templates/EntityTemplate/Templates/MonoEntityTemplate.cs index 8ff896a..62b5bd3 100644 --- a/src/Templates/EntityTemplate/Templates/MonoEntityTemplate.cs +++ b/src/Templates/EntityTemplate/Templates/MonoEntityTemplate.cs @@ -19,7 +19,7 @@ namespace DCFApixels.DragonECS public class MonoEntityTemplate : MonoEntityTemplateBase, ITemplateInternal { [SerializeReference] - [ReferenceButton(typeof(IComponentTemplate))] + [ReferenceButton(true, typeof(IComponentTemplate))] private IComponentTemplate[] _components; #region Properties diff --git a/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs b/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs index 6c4abf3..4c45459 100644 --- a/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs +++ b/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs @@ -18,7 +18,7 @@ namespace DCFApixels.DragonECS public class ScriptableEntityTemplate : ScriptableEntityTemplateBase, ITemplateInternal { [SerializeReference] - [ReferenceButton(typeof(IComponentTemplate))] + [ReferenceButton(true, typeof(IComponentTemplate))] private IComponentTemplate[] _components; #region Properties