Files
Fishing2/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs

84 lines
2.2 KiB
C#

// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System.Collections.Generic;
using FairyGUI;
namespace NBF
{
public partial class HomeMainPage : HomePageBase
{
private ButtonNavigate navigate;
private void OnInited()
{
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);
this.AutoListenInput();
}
protected override void OnShow()
{
InputManager.OnUICanceled += OnUICanceled;
UseBottomMenu();
// Model.LoadAsset(0);
// Model.SetBackground(Panel.Back.GetChild("back"));//, Panel.Back.GetChild("icon")
}
protected override void OnHide()
{
InputManager.OnUICanceled -= OnUICanceled;
}
private void OnUICanceled(string action)
{
if (!Panel.IsTop) return;
if (action == InputDef.UI.SubPrev)
{
}
else if (action == InputDef.UI.SubNext)
{
}
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();
}
}
private void UseBottomMenu()
{
BottomMenu.Use(Panel);
BottomMenu.AddRightButton(InputDef.UI.Enter);
BottomMenu.AddRightButton(InputDef.UI.Back);
}
}
}