update editors

This commit is contained in:
Mikhail 2024-10-12 23:00:59 +08:00
parent 1114cdce23
commit d4d59b8c66
7 changed files with 17 additions and 28 deletions

View File

@ -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)
{

View File

@ -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)

View File

@ -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:

View File

@ -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)
{
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;
return componentProperty == null ? prop : componentProperty;
}
return 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:

View File

@ -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

View File

@ -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

View File

@ -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