新Head
This commit is contained in:
35
Assets/Scripts/DynamicUI/Drawers/ParameterTextDrawer.cs
Normal file
35
Assets/Scripts/DynamicUI/Drawers/ParameterTextDrawer.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user