using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using UnityEngine.UI; using UnityEngine.EventSystems; public class OnKeyboardButton : MonoBehaviour, ISelectHandler, IDeselectHandler { public string key; public string altKey; private TextMeshProUGUI buttonText; private Button thisButton; private Color defaultTextColor = new Color(0.6431373f, 0.6431373f, 0.6431373f, 1); [SerializeField] private bool isSymbolsKey; [SerializeField] private bool isEnterKey; [SerializeField] private bool isDeleteKey; [SerializeField] private bool isShiftKey; [SerializeField] private bool isSpaceKey; private bool _switchToSymbols; public bool SwitchToSymbols { get => _switchToSymbols; set { _switchToSymbols = value; if (_switchToSymbols) { buttonText.text = altKey; } else { buttonText.text = key; } } } private bool _capitalizeCharacters; public bool CapitalizeCharacters { get => _capitalizeCharacters; set { _capitalizeCharacters = value; if (!IsSymbolsKeys()) { if (_capitalizeCharacters) { key = key.ToUpper(); buttonText.text = key.ToUpper(); } else { key = key.ToLower(); buttonText.text = key.ToLower(); } } } } private bool IsSymbolsKeys() { return SwitchToSymbols || isEnterKey || isDeleteKey || isSpaceKey || isSymbolsKey || isShiftKey; } private void Awake() { buttonText = GetComponentInChildren(); thisButton = GetComponent