com.alicizax.unity.framework/Runtime/Debugger/DebuggerComponent.InputAccelerationInformationWindow.cs
陈思海 3f895266f1 重构Runtime模式下Debugg模块为UI ToolKit绘制
重构Runtime模式下Debugg模块为UI ToolKit绘制
2026-04-21 13:01:55 +08:00

37 lines
1.5 KiB
C#

using UnityEngine;
using UnityEngine.UIElements;
namespace AlicizaX.Debugger.Runtime
{
public sealed partial class DebuggerComponent
{
private sealed class InputAccelerationInformationWindow : PollingDebuggerWindowBase
{
protected override void BuildWindow(VisualElement root)
{
VisualElement section = CreateSection("Input Acceleration", out VisualElement card);
card.Add(CreateRow("Acceleration", Input.acceleration.ToString()));
card.Add(CreateRow("Acceleration Event Count", Input.accelerationEventCount.ToString()));
card.Add(CreateRow("Acceleration Events", GetAccelerationEventsString(Input.accelerationEvents)));
root.Add(section);
}
private string GetAccelerationEventString(AccelerationEvent accelerationEvent)
{
return Utility.Text.Format("{0}, {1}", accelerationEvent.acceleration, accelerationEvent.deltaTime);
}
private string GetAccelerationEventsString(AccelerationEvent[] accelerationEvents)
{
string[] accelerationEventStrings = new string[accelerationEvents.Length];
for (int i = 0; i < accelerationEvents.Length; i++)
{
accelerationEventStrings[i] = GetAccelerationEventString(accelerationEvents[i]);
}
return string.Join("; ", accelerationEventStrings);
}
}
}
}