34 lines
768 B
C#
34 lines
768 B
C#
|
using System;
|
|||
|
using TMPro;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace HK.Keyboard
|
|||
|
{
|
|||
|
public class KeyBind : MonoBehaviour
|
|||
|
{
|
|||
|
[SerializeField] public string keyName;
|
|||
|
[SerializeField] public bool isPic = false;
|
|||
|
[SerializeField] public Image image;
|
|||
|
public Action<string> onClickAction;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
if (isPic)
|
|||
|
{
|
|||
|
image.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// GetComponentInChildren<TMP_Text>().text = keyName;
|
|||
|
}
|
|||
|
|
|||
|
GetComponent<Button>().onClick.AddListener(OnClick);
|
|||
|
}
|
|||
|
|
|||
|
private void OnClick()
|
|||
|
{
|
|||
|
onClickAction?.Invoke(keyName);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|