Files
zeling_v2/Assets/_Game/Scripts/UI/InputDeviceIconSetSO.cs

32 lines
1.1 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
{
public string BindingPath; // InputSystem binding pathe.g. "<Keyboard>/space"
public Sprite Icon;
}
[SerializeField] private IconEntry[] _entries;
/// <summary>根据 binding path 查找对应图标;未找到返回 null。</summary>
public Sprite GetIcon(string bindingPath)
{
if (_entries == null) return null;
foreach (var entry in _entries)
if (entry.BindingPath == bindingPath) return entry.Icon;
return null;
}
}
}