按键绑定功能
This commit is contained in:
@@ -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));
|
||||
|
||||
29
Assets/Scripts/UI/Settings/KeyboardInput.Designer.cs
generated
Normal file
29
Assets/Scripts/UI/Settings/KeyboardInput.Designer.cs
generated
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ddb059fe879d5c4abe82933558551a2
|
||||
27
Assets/Scripts/UI/Settings/KeyboardInput.cs
Normal file
27
Assets/Scripts/UI/Settings/KeyboardInput.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Settings/KeyboardInput.cs.meta
Normal file
2
Assets/Scripts/UI/Settings/KeyboardInput.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ed06aa0989ac484689d7c696bcf8246
|
||||
29
Assets/Scripts/UI/Settings/SettingInputItem.Designer.cs
generated
Normal file
29
Assets/Scripts/UI/Settings/SettingInputItem.Designer.cs
generated
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3336f2973a5dd242a9fed2120d8b75b
|
||||
36
Assets/Scripts/UI/Settings/SettingInputItem.cs
Normal file
36
Assets/Scripts/UI/Settings/SettingInputItem.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Settings/SettingInputItem.cs.meta
Normal file
2
Assets/Scripts/UI/Settings/SettingInputItem.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd7a19031ef9b1143997dca07c932a46
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user