2024-05-13 18:21:51 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
using DCFApixels.DragonECS.Unity.Internal;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS.Unity.Editors
|
|
|
|
|
{
|
|
|
|
|
[CustomPropertyDrawer(typeof(entlong))]
|
2024-09-14 23:30:11 +08:00
|
|
|
|
internal class EntlongDrawer : ExtendedPropertyDrawer
|
2024-05-13 18:21:51 +08:00
|
|
|
|
{
|
2025-04-16 09:36:51 +08:00
|
|
|
|
private float heightCache = 0;
|
2024-09-14 23:30:11 +08:00
|
|
|
|
protected override void DrawCustom(Rect position, SerializedProperty property, GUIContent label)
|
2024-05-13 18:21:51 +08:00
|
|
|
|
{
|
2025-04-16 09:36:51 +08:00
|
|
|
|
Rect labelRect, hyperlinkButtonRect;
|
|
|
|
|
(labelRect, position) = position.HorizontalSliceLeft(EditorGUIUtility.labelWidth * 0.65f);
|
|
|
|
|
(position, hyperlinkButtonRect) = position.HorizontalSliceRight(18f);
|
|
|
|
|
|
|
|
|
|
bool drawFoldout = property.hasMultipleDifferentValues == false;
|
2024-05-13 18:21:51 +08:00
|
|
|
|
|
2025-04-16 09:36:51 +08:00
|
|
|
|
bool isExpanded = false;
|
|
|
|
|
if (drawFoldout)
|
|
|
|
|
{
|
|
|
|
|
EditorGUI.BeginChangeCheck();
|
|
|
|
|
isExpanded = EditorGUI.Foldout(labelRect, property.isExpanded, label);
|
|
|
|
|
if (EditorGUI.EndChangeCheck())
|
|
|
|
|
{
|
|
|
|
|
property.isExpanded = isExpanded;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-05-13 18:21:51 +08:00
|
|
|
|
EditorGUI.LabelField(labelRect, label);
|
|
|
|
|
}
|
2025-04-16 09:36:51 +08:00
|
|
|
|
|
|
|
|
|
EntitySlotInfo entity = new EntitySlotInfo(property.FindPropertyRelative("_full").longValue);
|
|
|
|
|
EcsWorld.TryGetWorld(entity.world, out EcsWorld world);
|
|
|
|
|
|
|
|
|
|
if (drawFoldout && isExpanded)
|
|
|
|
|
{
|
|
|
|
|
using (EcsGUI.UpIndentLevel())
|
|
|
|
|
{
|
|
|
|
|
if (world != null && world.IsAlive(entity.id, entity.gen))
|
|
|
|
|
{
|
|
|
|
|
EcsGUI.Layout.DrawRuntimeComponents(entity.id, world, false, false);
|
|
|
|
|
if (Event.current.type == EventType.Layout)
|
|
|
|
|
{
|
|
|
|
|
heightCache = GUILayoutUtility.GetLastRect().height;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
EcsGUI.EntityField(position, property);
|
|
|
|
|
using (EcsGUI.SetEnable(world != null))
|
|
|
|
|
{
|
|
|
|
|
EcsGUI.EntityHyperlinkButton(hyperlinkButtonRect, world, entity.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
|
|
|
|
{
|
|
|
|
|
const float UNITY_HEIGHT_CONSTANT = 18f;
|
|
|
|
|
if (property.hasMultipleDifferentValues)
|
|
|
|
|
{
|
|
|
|
|
return UNITY_HEIGHT_CONSTANT;
|
|
|
|
|
}
|
|
|
|
|
return Mathf.Max(heightCache, UNITY_HEIGHT_CONSTANT);
|
2024-05-13 18:21:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|