using System; using System.Linq; using BITKit.Mod; using BITKit.UX.Hotkey; using Cysharp.Threading.Tasks; using UnityEngine; using UnityEngine.UIElements; namespace BITKit.UX { public class UXRadialMenu : UIToolKitPanel { protected override string DocumentPath => "ui_radial_menu"; public override bool CloseWhenClickOutside => true; public override bool AllowCursor => true; private VisualTreeAsset _template; [UXBindPath("radialMenu-container")] private VisualElement _container; [UXBindPath("info-label")] private Label _infoLabel; public IHotkeyCollection HotkeyCollection { get; set; } public UXRadialMenu(IUXService uxService) : base(uxService) { OnInitiatedAsync += InitiatedAsync; } private async UniTask InitiatedAsync() { _container.Clear(); _template =await ModService.LoadAsset("ui_radial_menu-template"); } protected override void OnPanelEntry() { base.OnPanelEntry(); _infoLabel.text = "选择快速动作"; if (HotkeyCollection is null) { _infoLabel.text = "没有快速动作"; return; } var count = HotkeyCollection.Hotkeys.Count(); if (count is 0) { _infoLabel.text = "目前没有快速动作"; } for (var i = 0; i < count; i++) { var hotkey = HotkeyCollection.Hotkeys.ElementAt(i); var angle = 360 / count * i; var pos = Quaternion.Euler(0, 0, angle) * Vector3.up * 384; pos.y *= 0.64f; var container = _container.Create(_template.CloneTree); var button = container.Get