using Ichni.RhythmGame; using Lean.Pool; using UnityEngine; namespace Ichni.Editor { /// /// 参数文本 Drawer,绑定字段并显示只读文本,支持自动更新。 /// 创建 DynamicUIParameterText。 /// public class ParameterTextDrawer : IPropertyDrawer { public int DefaultSpan => 1; public float DefaultHeight => LayoutPacker.DefaultRowHeight; public DynamicUIElement Draw(DrawContext ctx) { var go = LeanPool.Spawn(ctx.Registry.GetPrefab("parameterText"), ctx.Parent); var element = go.GetComponent(); element.Initialize(ctx.Target, ctx.Label, ctx.FieldName); if (ctx.AutoUpdate) { element.SetAutoUpdate(true); } int span = ctx.OverrideSpan ?? DefaultSpan; float height = ctx.OverrideHeight ?? DefaultHeight; element.SetLayoutSize(span * LayoutPacker.TotalRowWidth / LayoutPacker.MaxSpanPerRow, height); return element; } } }