// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖 using System; using UnityEngine; using FairyGUI; using NBC; namespace NBF { public partial class BottomMenu : GComponent { private IUIPanel _panel; private void OnInited() { List.onClickItem.Add(OnClickItem); } private void OnClickItem(EventContext context) { var item = context.data as BtnTitleInputControl; if (item == null) return; item.OnAction?.Invoke(); } public void Use(IUIPanel panel) { _panel = panel; List.RemoveChildrenToPool(); LeftList.RemoveChildrenToPool(); InputManager.OnUICanceled += OnAction; // AddButtonItem(OnUse, ""); // AddButtonItem(OnTab, InputDef.UI.Tab); // AddButtonItem(OnEnter, InputDef.UI.Enter); // AddButtonItem(OnBack, InputDef.UI.Back); } private void AddButtonItem(Action action, string actionName) { if (action != null) { if (List.AddItemFromPool() is BtnTitleInputControl item) { item.OnAction = action; item.ActionName = actionName; } } } private void OnAction(string action) { if (_panel == null || !_panel.IsShowing || !_panel.IsTop) return; var children = List.GetChildren(); foreach (var child in children) { if (child is BtnTitleInputControl item) { if (action == item.ActionName) { item.OnAction?.Invoke(); } } } } } }