按键绑定功能

This commit is contained in:
bob
2025-06-19 18:15:15 +08:00
parent 240a6d3887
commit 8a8821c2e6
72 changed files with 1196 additions and 401 deletions

View File

@@ -8,6 +8,8 @@ namespace NBF
{
public static void BindAll()
{
UIObjectFactory.SetPackageItemExtension(KeyboardInput.URL, typeof(KeyboardInput));
UIObjectFactory.SetPackageItemExtension(SettingInputItem.URL, typeof(SettingInputItem));
UIObjectFactory.SetPackageItemExtension(SettingItem.URL, typeof(SettingItem));
UIObjectFactory.SetPackageItemExtension(IntroduceTag.URL, typeof(IntroduceTag));
UIObjectFactory.SetPackageItemExtension(HomeMainPage.URL, typeof(HomeMainPage));

View File

@@ -0,0 +1,29 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class KeyboardInput
{
public const string URL = "ui://hxr7rc7p5dtx1b";
public Controller state;
public GImage bottomLine;
public GTextField TextKeyboard;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
state = GetController("state");
bottomLine = (GImage)GetChild("bottomLine");
TextKeyboard = (GTextField)GetChild("TextKeyboard");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0ddb059fe879d5c4abe82933558551a2

View File

@@ -0,0 +1,27 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using UnityEngine;
using FairyGUI;
using NBC;
using NBF.Setting;
using UnityEngine.InputSystem;
namespace NBF
{
public partial class KeyboardInput : GButton
{
private void OnInited()
{
}
public void SetData(InputOption option)
{
TextKeyboard.visible = false;
if (option is KeyBoardOption)
{
TextKeyboard.visible = true;
TextKeyboard.text = option.GetDisplayString();
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2ed06aa0989ac484689d7c696bcf8246

View File

@@ -0,0 +1,29 @@
/**本脚本为自动生成每次生成会覆盖请勿手动修改生成插件文档及项目地址https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/
using FairyGUI;
using FairyGUI.Utils;
using NBC;
namespace NBF
{
public partial class SettingInputItem
{
public const string URL = "ui://hxr7rc7p5dtx1c";
public GImage back;
public GTextField TextName;
public KeyboardInput BtnKeyboard;
public override void ConstructFromXML(XML xml)
{
base.ConstructFromXML(xml);
back = (GImage)GetChild("back");
TextName = (GTextField)GetChild("TextName");
BtnKeyboard = (KeyboardInput)GetChild("BtnKeyboard");
OnInited();
UILanguage.TrySetComponentLanguage(this);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a3336f2973a5dd242a9fed2120d8b75b

View File

@@ -0,0 +1,36 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System.Globalization;
using UnityEngine;
using FairyGUI;
using NBC;
using NBF.Setting;
namespace NBF
{
public partial class SettingInputItem : GButton
{
public OptionBase Option;
private void OnInited()
{
}
public void SetData(OptionBase option)
{
Option = option;
TextName.SetLanguage(Option.Name);
SetShow();
}
private void SetShow()
{
UpdateValueText();
}
private void UpdateValueText()
{
BtnKeyboard.SetData(Option as InputOption);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fd7a19031ef9b1143997dca07c932a46

View File

@@ -33,6 +33,10 @@ namespace NBF
Slider.max = range.MaxValue;
Slider.wholeNumbers = true;
}
else if (option is KeyBoardOption keyBoardOption)
{
style.selectedIndex = 2;
}
TextName.SetLanguage(Option.Name);
SetShow();

View File

@@ -64,7 +64,7 @@ namespace NBF
{
// TextTitle.text = Lan.Get(_currentGroup);
_nowSelectIndex = -1;
List.RemoveChildrenToPool();
if (string.IsNullOrEmpty(_currentTab)) return;
var options = Settings.Instance.GetOptionsByTab(_currentTab);
Dictionary<string, List<OptionBase>> groupOptions = new Dictionary<string, List<OptionBase>>();
@@ -80,6 +80,10 @@ namespace NBF
}
_canSelectIndex.Clear();
List.RemoveChildrenToPool();
var url = UIPackage.GetItemURL(UIPackName, "SettingSubTitleItem");
foreach (var key in groupOptions.Keys)
{
@@ -91,11 +95,23 @@ namespace NBF
foreach (var option in value)
{
if (List.AddItemFromPool() is SettingItem item)
if (option is InputOption)
{
item.SetData(option);
var index = List.GetChildIndex(item);
_canSelectIndex.Add(index);
if (List.AddItemFromPool(SettingInputItem.URL) is SettingInputItem item)
{
item.SetData(option);
var index = List.GetChildIndex(item);
_canSelectIndex.Add(index);
}
}
else
{
if (List.AddItemFromPool() is SettingItem item)
{
item.SetData(option);
var index = List.GetChildIndex(item);
_canSelectIndex.Add(index);
}
}
}
}