39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using Ichni.RhythmGame;
|
|
using Lean.Pool;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Ichni.Editor
|
|
{
|
|
/// <summary>
|
|
/// 处理 Vector3 类型的 Drawer。
|
|
/// 创建 DynamicUIVector3InputField。
|
|
/// </summary>
|
|
public class Vector3FieldDrawer : IPropertyDrawer
|
|
{
|
|
public int DefaultSpan => 3;
|
|
public float DefaultHeight => LayoutPacker.DefaultRowHeight;
|
|
|
|
public DynamicUIElement Draw(DrawContext ctx)
|
|
{
|
|
var go = LeanPool.Spawn(ctx.Registry.GetPrefab("vector3InputField"), ctx.Parent);
|
|
var element = go.GetComponent<DynamicUIVector3InputField>();
|
|
|
|
element.Initialize(ctx.Target, ctx.Label, ctx.FieldName);
|
|
|
|
if (ctx.AutoUpdate)
|
|
{
|
|
element.SetAutoUpdate(true);
|
|
}
|
|
|
|
DynamicUIElement.DisableNavigation(element.inputFieldX, element.inputFieldY, element.inputFieldZ);
|
|
|
|
int span = ctx.OverrideSpan ?? DefaultSpan;
|
|
float height = ctx.OverrideHeight ?? DefaultHeight;
|
|
element.SetLayoutSize(span * LayoutPacker.TotalRowWidth / LayoutPacker.MaxSpanPerRow, height);
|
|
|
|
return element;
|
|
}
|
|
}
|
|
}
|