按键绑定功能
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
namespace NBF.Setting
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public abstract class InputOption : OptionBase
|
||||
{
|
||||
public abstract InputAction InputAction { get; }
|
||||
|
||||
protected override int DefaultValue => 0;
|
||||
|
||||
public override string GetDisplayString()
|
||||
{
|
||||
if (InputAction != null)
|
||||
{
|
||||
return InputAction.GetBindingDisplayString();
|
||||
}
|
||||
|
||||
return base.GetDisplayString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
namespace NBF.Setting
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public abstract class KeyBoardOption : InputOption
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
namespace NBF.Setting
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public class InputAddBobSetting : KeyBoardOption
|
||||
{
|
||||
private int _defaultKey;
|
||||
public override string Name => "InputAddBob";
|
||||
public override string Group => SettingsDef.Group.Keyboard;
|
||||
public override string Tab => SettingsDef.Tab.Keyboard;
|
||||
|
||||
protected override int DefaultValue => _defaultKey;
|
||||
public override InputAction InputAction => InputManager.PlayerInputControl.Player.AddBob;
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public class InputChatSetting : KeyBoardOption
|
||||
{
|
||||
private int _defaultKey;
|
||||
public override string Name => "InputChat";
|
||||
public override string Group => SettingsDef.Group.Keyboard;
|
||||
public override string Tab => SettingsDef.Tab.Keyboard;
|
||||
|
||||
public override InputAction InputAction => InputManager.PlayerInputControl.Player.Chat;
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
// PlayerInputControl.PlayerActions
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a63f66ee0a384cf0a163c33dfa2f3c36
|
||||
timeCreated: 1750308320
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public class InputHelpSetting : KeyBoardOption
|
||||
{
|
||||
public override string Name => "InputHelp";
|
||||
public override string Group => SettingsDef.Group.Keyboard;
|
||||
public override string Tab => SettingsDef.Tab.Keyboard;
|
||||
|
||||
public override InputAction InputAction => InputManager.PlayerInputControl.Player.Help;
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b77e15344964a9ab0b1ecafcad3d03d
|
||||
timeCreated: 1750308298
|
||||
@@ -0,0 +1,17 @@
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public class InputSubBobSetting : KeyBoardOption
|
||||
{
|
||||
public override string Name => "InputSubBob";
|
||||
public override string Group => SettingsDef.Group.Keyboard;
|
||||
public override string Tab => SettingsDef.Tab.Keyboard;
|
||||
|
||||
public override InputAction InputAction => InputManager.PlayerInputControl.Player.SubBob;
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea72a2c910474d5ca4e96d2c881797d8
|
||||
timeCreated: 1750307386
|
||||
@@ -0,0 +1,17 @@
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public class InputToBagSetting : KeyBoardOption
|
||||
{
|
||||
public override string Name => "InputToBag";
|
||||
public override string Group => SettingsDef.Group.Keyboard;
|
||||
public override string Tab => SettingsDef.Tab.Keyboard;
|
||||
|
||||
public override InputAction InputAction => InputManager.PlayerInputControl.Player.ToBag;
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 906eac0772874939a5223e1115d5dfe0
|
||||
timeCreated: 1750308244
|
||||
@@ -0,0 +1,19 @@
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public class InputUseTelescopeSetting : KeyBoardOption
|
||||
{
|
||||
public override string Name => "InputUseTelescope";
|
||||
public override string Group => SettingsDef.Group.Keyboard;
|
||||
public override string Tab => SettingsDef.Tab.Keyboard;
|
||||
|
||||
public override InputAction InputAction => InputManager.PlayerInputControl.Player.UseTelescope;
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24089404fdb7424284ecafcd23d1537f
|
||||
timeCreated: 1750308215
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace NBF.Setting
|
||||
{
|
||||
public class InputUseTorchSetting : KeyBoardOption
|
||||
{
|
||||
public override string Name => "InputUseTorch";
|
||||
public override string Group => SettingsDef.Group.Keyboard;
|
||||
public override string Tab => SettingsDef.Tab.Keyboard;
|
||||
|
||||
public override InputAction InputAction => InputManager.PlayerInputControl.Player.UseTorch;
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12a79769a6534afa8212293adfa1e48a
|
||||
timeCreated: 1750307422
|
||||
@@ -309,6 +309,15 @@ namespace NBF
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
},
|
||||
{
|
||||
""name"": ""OpenQuick"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""1b9b87d1-77ad-46ac-b39f-94ca5633b23d"",
|
||||
""expectedControlType"": """",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
},
|
||||
{
|
||||
""name"": ""Quick1"",
|
||||
""type"": ""Button"",
|
||||
@@ -981,6 +990,17 @@ namespace NBF
|
||||
""action"": ""Use2"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""cf3a4ade-205f-4ae1-914f-4126358122cf"",
|
||||
""path"": ""<Keyboard>/0"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""OpenQuick"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1511,6 +1531,7 @@ namespace NBF
|
||||
m_Player_Keepnet = m_Player.FindAction("Keepnet", throwIfNotFound: true);
|
||||
m_Player_Make = m_Player.FindAction("Make", throwIfNotFound: true);
|
||||
m_Player_Map = m_Player.FindAction("Map", throwIfNotFound: true);
|
||||
m_Player_OpenQuick = m_Player.FindAction("OpenQuick", throwIfNotFound: true);
|
||||
m_Player_Quick1 = m_Player.FindAction("Quick1", throwIfNotFound: true);
|
||||
m_Player_Quick2 = m_Player.FindAction("Quick2", throwIfNotFound: true);
|
||||
m_Player_Quick3 = m_Player.FindAction("Quick3", throwIfNotFound: true);
|
||||
@@ -1640,6 +1661,7 @@ namespace NBF
|
||||
private readonly InputAction m_Player_Keepnet;
|
||||
private readonly InputAction m_Player_Make;
|
||||
private readonly InputAction m_Player_Map;
|
||||
private readonly InputAction m_Player_OpenQuick;
|
||||
private readonly InputAction m_Player_Quick1;
|
||||
private readonly InputAction m_Player_Quick2;
|
||||
private readonly InputAction m_Player_Quick3;
|
||||
@@ -1759,6 +1781,10 @@ namespace NBF
|
||||
/// </summary>
|
||||
public InputAction @Map => m_Wrapper.m_Player_Map;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Player/OpenQuick".
|
||||
/// </summary>
|
||||
public InputAction @OpenQuick => m_Wrapper.m_Player_OpenQuick;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Player/Quick1".
|
||||
/// </summary>
|
||||
public InputAction @Quick1 => m_Wrapper.m_Player_Quick1;
|
||||
@@ -1900,6 +1926,9 @@ namespace NBF
|
||||
@Map.started += instance.OnMap;
|
||||
@Map.performed += instance.OnMap;
|
||||
@Map.canceled += instance.OnMap;
|
||||
@OpenQuick.started += instance.OnOpenQuick;
|
||||
@OpenQuick.performed += instance.OnOpenQuick;
|
||||
@OpenQuick.canceled += instance.OnOpenQuick;
|
||||
@Quick1.started += instance.OnQuick1;
|
||||
@Quick1.performed += instance.OnQuick1;
|
||||
@Quick1.canceled += instance.OnQuick1;
|
||||
@@ -2016,6 +2045,9 @@ namespace NBF
|
||||
@Map.started -= instance.OnMap;
|
||||
@Map.performed -= instance.OnMap;
|
||||
@Map.canceled -= instance.OnMap;
|
||||
@OpenQuick.started -= instance.OnOpenQuick;
|
||||
@OpenQuick.performed -= instance.OnOpenQuick;
|
||||
@OpenQuick.canceled -= instance.OnOpenQuick;
|
||||
@Quick1.started -= instance.OnQuick1;
|
||||
@Quick1.performed -= instance.OnQuick1;
|
||||
@Quick1.canceled -= instance.OnQuick1;
|
||||
@@ -2529,6 +2561,13 @@ namespace NBF
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnMap(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "OpenQuick" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnOpenQuick(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "Quick1" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
|
||||
@@ -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