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.
This commit is contained in:
@@ -13,18 +13,27 @@ namespace BaseGames.UI
|
||||
[System.Serializable]
|
||||
public struct IconEntry
|
||||
{
|
||||
public string BindingPath; // InputSystem binding path,e.g. "<Keyboard>/space"
|
||||
public Sprite Icon;
|
||||
[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) return null;
|
||||
if (_entries == null || string.IsNullOrEmpty(bindingPath)) return null;
|
||||
// 先精确匹配,再做路径前缀不区分大小写匹配(兼容大小写差异)
|
||||
foreach (var entry in _entries)
|
||||
if (entry.BindingPath == bindingPath) return entry.Icon;
|
||||
if (string.Equals(entry.BindingPath, bindingPath, System.StringComparison.OrdinalIgnoreCase))
|
||||
return entry.Icon;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user