方向键控制

This commit is contained in:
bob
2025-06-04 12:12:11 +08:00
parent d76b763fbf
commit 34cff550fa
19 changed files with 340 additions and 76 deletions

View File

@@ -13,6 +13,7 @@ namespace NBF
public HomeButtonGroups OpGroup;
public BottomMenu BottomMenu;
public GButton BtnTest;
public override void ConstructFromXML(XML xml)
{
@@ -20,6 +21,7 @@ namespace NBF
OpGroup = (HomeButtonGroups)GetChild("OpGroup");
BottomMenu = (BottomMenu)GetChild("BottomMenu");
BtnTest = (GButton)GetChild("BtnTest");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}

View File

@@ -3,16 +3,29 @@
using System.Collections.Generic;
using FairyGUI;
using NBC;
using UnityEngine;
namespace NBF
{
public partial class HomeMainPage : HomePageBase
{
private List<GButton> _buttons = new List<GButton>();
private ButtonNavigate navigate;
private void OnInited()
{
_buttons.Add(OpGroup.BtnGo);
List<GButton> buttons = new List<GButton>();
var children = OpGroup.GetChildren();
foreach (var child in children)
{
if (child is GButton button)
{
buttons.Add(button);
}
}
buttons.Add(BtnTest);
navigate = new ButtonNavigate(buttons);
}
protected override void OnShow()
@@ -21,6 +34,7 @@ namespace NBF
UseBottomMenu();
}
protected override void OnHide()
{
InputManager.OnUICanceled -= OnUICanceled;
@@ -37,9 +51,23 @@ namespace NBF
}
else if (action == InputDef.UI.Up)
{
navigate.Up();
}
else if (action == InputDef.UI.Down)
{
navigate.Down();
}
else if (action == InputDef.UI.Right)
{
navigate.Right();
}
else if (action == InputDef.UI.Left)
{
navigate.Left();
}
else if (action == InputDef.UI.Enter)
{
navigate.Click();
}
}