34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
namespace BaseGames.Input
|
|
{
|
|
/// <summary>
|
|
/// 在运行时启用 InputReaderSO 的 ActionMap。
|
|
/// 挂在 Persistent 场景的 InputReaderHolder 上。
|
|
/// _inputReader 必须在 Inspector 中赋值,框架不提供运行时自动查找回退。
|
|
/// </summary>
|
|
public sealed class InputReaderBootstrap : MonoBehaviour
|
|
{
|
|
[SerializeField] private InputReaderSO _inputReader;
|
|
|
|
private void Awake()
|
|
{
|
|
Debug.Assert(_inputReader != null,
|
|
"[InputReaderBootstrap] _inputReader 未在 Inspector 中赋值!请在 Persistent 场景的 InputReaderHolder 上手动指定 InputReaderSO 资产。",
|
|
this);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
if (_inputReader == null) return;
|
|
_inputReader.LoadBindingOverrides(); // 从 PlayerPrefs 恢复用户自定义绑定
|
|
_inputReader.EnableGameplayInput();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
_inputReader?.DisableAllInput();
|
|
}
|
|
}
|
|
}
|