This commit is contained in:
SoulliesOfficial
2026-06-09 01:43:55 -04:00
parent 0fb72f5bba
commit 5fc1392747
171 changed files with 30149 additions and 22331 deletions

View File

@@ -0,0 +1,40 @@
using Lean.Pool;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace Ichni.Editor
{
/// <summary>
/// 按钮 Drawer不绑定数据字段。
/// 创建 DynamicUIButton 并绑定 ButtonAction。
/// </summary>
public class ButtonDrawer : IPropertyDrawer
{
public int DefaultSpan => 1;
public float DefaultHeight => LayoutPacker.DefaultRowHeight;
public DynamicUIElement Draw(DrawContext ctx)
{
var go = LeanPool.Spawn(ctx.Registry.GetPrefab("button"), ctx.Parent);
var element = go.GetComponent<DynamicUIButton>();
element.SetText(ctx.Label);
element.Initialize(ctx.Target, ctx.Label, string.Empty);
if (ctx.ButtonAction != null)
{
UnityAction action = () => ctx.ButtonAction();
element.ApplyFunction(action);
}
DynamicUIElement.DisableNavigation(element.button);
int span = ctx.OverrideSpan ?? DefaultSpan;
float height = ctx.OverrideHeight ?? DefaultHeight;
element.SetLayoutSize(span * LayoutPacker.TotalRowWidth / LayoutPacker.MaxSpanPerRow, height);
return element;
}
}
}