using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Example : MonoBehaviour
{
public List<KeyboardKey> keyboardKeys = new List<KeyboardKey>();
private void Update()
{
for (int i = 0; i < keyboardKeys.Count; i++)
{
var key = keyboardKeys[i];
if (Input.GetKeyDown(key.code))
{
// Делаем что-то с key.image
}
}
}
}
[Serializable]
public class KeyboardKey
{
public Image image;
public KeyCode code;
}