Files
zeling_v2/Assets/_Game/Scripts/UI/InputDeviceIconSetSO.cs
Joywayer e879efaa89 Add InputDeviceIconSetSO configuration guide and related documentation
- Created a new markdown file detailing the configuration of InputDeviceIconSetSO.
- Included sections on system architecture, field explanations, image specifications, and complete workflow from setup to runtime.
- Documented the automatic device recognition logic and provided troubleshooting for common issues.
- Added references to relevant files and scripts for easier navigation.
2026-05-23 00:10:23 +08:00

41 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using UnityEngine;
namespace BaseGames.UI
{
/// <summary>
/// 输入设备图标集 SO架构 10_UIModule §12
/// 存储一套设备(键鼠 or 手柄)所有按键对应的 Sprite。
/// 由 InputDeviceIconSwitcher 根据当前设备选择正确的图标集。
/// </summary>
[CreateAssetMenu(menuName = "BaseGames/UI/Input Device Icon Set", fileName = "InputDeviceIconSetSO")]
public class InputDeviceIconSetSO : ScriptableObject
{
[System.Serializable]
public struct IconEntry
{
[Tooltip("InputSystem 绑定路径,如 <Keyboard>/space 或 <Gamepad>/buttonSouth。改键后路径变化图标集中须包含全部可能按键的映射。")]
public string BindingPath;
public Sprite Icon;
}
[Tooltip("标识此图标集对应的输入设备类型(仅作编辑器说明,运行时由 InputIconService 选择)")]
[SerializeField] private InputDeviceType _deviceType;
[SerializeField] private IconEntry[] _entries;
/// <summary>此图标集对应的设备类型。</summary>
public InputDeviceType DeviceType => _deviceType;
/// <summary>根据 binding path 查找对应图标;未找到返回 null。</summary>
public Sprite GetIcon(string bindingPath)
{
if (_entries == null || string.IsNullOrEmpty(bindingPath)) return null;
// 先精确匹配,再做路径前缀不区分大小写匹配(兼容大小写差异)
foreach (var entry in _entries)
if (string.Equals(entry.BindingPath, bindingPath, System.StringComparison.OrdinalIgnoreCase))
return entry.Icon;
return null;
}
}
}