36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Ichni.RhythmGame;
|
||
using Lean.Pool;
|
||
using UnityEngine;
|
||
|
||
namespace Ichni.Editor
|
||
{
|
||
/// <summary>
|
||
/// 参数文本 Drawer,绑定字段并显示只读文本,支持自动更新。
|
||
/// 创建 DynamicUIParameterText。
|
||
/// </summary>
|
||
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<DynamicUIParameterText>();
|
||
|
||
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;
|
||
}
|
||
}
|
||
}
|