setting change

This commit is contained in:
Bob.Song
2026-02-02 17:58:39 +08:00
parent f33f61f515
commit 55a92d9b23
127 changed files with 803 additions and 222 deletions

View File

@@ -0,0 +1,73 @@
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
using UnityEngine;
using NBC;
using NBF.Setting;
using UnityEngine.InputSystem;
namespace NBF
{
public partial class SettingWaitInputPanel : UIPanel
{
private SettingItem _settingItem;
private InputOption _inputOption;
private InputActionRebindingExtensions.RebindingOperation rebindingOperation;
protected override void OnShow()
{
_settingItem = GetData() as SettingItem;
if (_settingItem == null)
{
Hide();
return;
}
if (_settingItem.Option is InputOption inputOption)
{
_inputOption = inputOption;
OnRebinding();
}
}
#region
private void OnRebinding()
{
// 开始重绑定操作
rebindingOperation = _inputOption.InputAction.PerformInteractiveRebinding(_inputOption.BindingIndex)
.OnMatchWaitForAnother(0.1f)
.OnComplete(operation => RebindComplete())
.OnCancel(operation => RebindCanceled())
.Start();
}
private void RebindComplete()
{
rebindingOperation.Dispose();
_inputOption.InputAction.Enable();
UpdateValueText();
}
private void RebindCanceled()
{
rebindingOperation.Dispose();
_inputOption.InputAction.Enable();
Hide();
}
private void UpdateValueText()
{
_settingItem.UpdateValueText();
Hide();
}
#endregion
[InputInvoke(InputDef.UI.Back)]
private void OnBack()
{
Hide();
}
}
}