mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 18:14:35 +08:00
update editors
This commit is contained in:
parent
1114cdce23
commit
d4d59b8c66
@ -705,7 +705,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
#region Other Elements
|
#region Other Elements
|
||||||
public static bool AddComponentButton(Rect position, out Rect dropDownRect)
|
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");
|
return GUI.Button(dropDownRect, "Add Component");
|
||||||
}
|
}
|
||||||
public static AddClearButton AddClearComponentButtons(Rect position, out Rect dropDownRect)
|
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)
|
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);
|
var (left, right) = RectUtility.HorizontalSliceLerp(position, 0.75f);
|
||||||
|
|
||||||
dropDownRect = left;
|
dropDownRect = left;
|
||||||
@ -1080,15 +1080,15 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
|
|
||||||
public static bool AddComponentButtons(out Rect dropDownRect)
|
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)
|
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)
|
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)
|
public static void DrawRuntimeComponents(entlong entity, bool isWithFoldout = true)
|
||||||
{
|
{
|
||||||
|
@ -198,7 +198,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
private IEnumerable<(T, ITypeMeta)> _itemMetaPairs;
|
private IEnumerable<(T, ITypeMeta)> _itemMetaPairs;
|
||||||
public MetaObjectsDropDown() : base(new AdvancedDropdownState())
|
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)
|
protected void Setup(IEnumerable<(T, ITypeMeta)> itemMetaPairs, string name = "Select Type...", bool isContainsNull = true)
|
||||||
|
@ -228,6 +228,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
GUILayout.Label(UnityEditorUtility.GetLabel(recordsProp.displayName), EditorStyles.boldLabel);
|
GUILayout.Label(UnityEditorUtility.GetLabel(recordsProp.displayName), EditorStyles.boldLabel);
|
||||||
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f)))
|
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f)))
|
||||||
{
|
{
|
||||||
|
GUILayout.Space(4f);
|
||||||
|
|
||||||
switch (EcsGUI.Layout.AddClearSystemButtons(out Rect dropDownRect))
|
switch (EcsGUI.Layout.AddClearSystemButtons(out Rect dropDownRect))
|
||||||
{
|
{
|
||||||
case EcsGUI.AddClearButton.Add:
|
case EcsGUI.AddClearButton.Add:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using DCFApixels.DragonECS.Unity.Internal;
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
using DCFApixels.DragonECS.Unity.RefRepairer.Editors;
|
using DCFApixels.DragonECS.Unity.RefRepairer.Editors;
|
||||||
using System;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditorInternal;
|
using UnityEditorInternal;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -58,28 +57,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
|
|
||||||
SerializedProperty componentProperty = prop;
|
SerializedProperty componentProperty = prop;
|
||||||
try
|
if (componentProperty.managedReferenceValue is ComponentTemplateBase customTemplate)
|
||||||
{
|
{
|
||||||
if (componentProperty.managedReferenceValue is ComponentTemplateBase customTemplate)
|
componentProperty = prop.FindPropertyRelative("component");
|
||||||
{
|
|
||||||
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;
|
return componentProperty == null ? prop : componentProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float OnReorderableComponentsListElementHeight(int index)
|
private float OnReorderableComponentsListElementHeight(int index)
|
||||||
{
|
{
|
||||||
var componentProperty = GetTargetProperty(_componentsProp.GetArrayElementAtIndex(index));
|
var componentProperty = GetTargetProperty(_componentsProp.GetArrayElementAtIndex(index));
|
||||||
@ -194,11 +179,12 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
DrawTop(Target, _componentsProp);
|
DrawTop(Target, _componentsProp);
|
||||||
_reorderableComponentsList.DoLayoutList();
|
_reorderableComponentsList.DoLayoutList();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void DrawTop(ITemplateInternal target, SerializedProperty componentsProp)
|
private void DrawTop(ITemplateInternal target, SerializedProperty componentsProp)
|
||||||
{
|
{
|
||||||
|
GUILayout.Space(2f);
|
||||||
|
|
||||||
switch (EcsGUI.Layout.AddClearComponentButtons(out Rect rect))
|
switch (EcsGUI.Layout.AddClearComponentButtons(out Rect rect))
|
||||||
{
|
{
|
||||||
case EcsGUI.AddClearButton.Add:
|
case EcsGUI.AddClearButton.Add:
|
||||||
|
@ -61,6 +61,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
protected T component;
|
protected T component;
|
||||||
[SerializeField]
|
[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.
|
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
|
#region Properties
|
||||||
|
@ -19,7 +19,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public class MonoEntityTemplate : MonoEntityTemplateBase, ITemplateInternal
|
public class MonoEntityTemplate : MonoEntityTemplateBase, ITemplateInternal
|
||||||
{
|
{
|
||||||
[SerializeReference]
|
[SerializeReference]
|
||||||
[ReferenceButton(typeof(IComponentTemplate))]
|
[ReferenceButton(true, typeof(IComponentTemplate))]
|
||||||
private IComponentTemplate[] _components;
|
private IComponentTemplate[] _components;
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
@ -18,7 +18,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public class ScriptableEntityTemplate : ScriptableEntityTemplateBase, ITemplateInternal
|
public class ScriptableEntityTemplate : ScriptableEntityTemplateBase, ITemplateInternal
|
||||||
{
|
{
|
||||||
[SerializeReference]
|
[SerializeReference]
|
||||||
[ReferenceButton(typeof(IComponentTemplate))]
|
[ReferenceButton(true, typeof(IComponentTemplate))]
|
||||||
private IComponentTemplate[] _components;
|
private IComponentTemplate[] _components;
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
Loading…
Reference in New Issue
Block a user