Files
ichni_Creator_Studio/Assets/Scripts/DynamicUI/Drawers/HintTextDrawer.cs
SoulliesOfficial 5fc1392747 新Head
2026-06-09 01:43:55 -04:00

39 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Lean.Pool;
using UnityEngine;
namespace Ichni.Editor
{
/// <summary>
/// 提示文本 Drawer支持静态文本和 Func&lt;string&gt; 动态文本。
/// 创建 DynamicUIHintText。
/// </summary>
public class HintTextDrawer : IPropertyDrawer
{
public int DefaultSpan => 1;
public float DefaultHeight => LayoutPacker.DefaultRowHeight;
public DynamicUIElement Draw(DrawContext ctx)
{
var go = LeanPool.Spawn(ctx.Registry.GetPrefab("hintText"), ctx.Parent);
var element = go.GetComponent<DynamicUIHintText>();
element.Initialize(ctx.Target, string.Empty, string.Empty);
if (ctx.DynamicText != null)
{
element.SetUpdatingContent(ctx.DynamicText);
}
else if (ctx.StaticText != null)
{
element.SetContent(ctx.StaticText);
}
int span = ctx.OverrideSpan ?? DefaultSpan;
float height = ctx.OverrideHeight ?? DefaultHeight;
element.SetLayoutSize(span * LayoutPacker.TotalRowWidth / LayoutPacker.MaxSpanPerRow, height);
return element;
}
}
}