using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class SCKeyboardKey : MonoBehaviour,IPointerHandler { private Color color_Gray = new Color32(87, 87, b: 87, 255); private Color color_Blue = new Color32(76, 166, 255, 200); protected virtual void OnEnable() { } protected virtual void Start() { RegistKey(); } protected virtual void RegistKey() { PressableButton pressableButton = this.GetComponent(); TouchableButton touchableButton = this.GetComponent(); if (pressableButton && touchableButton) { InteractionEvent interActionEvent = new InteractionEvent(); interActionEvent.AddListener(OnNormalKeyClick); pressableButton.Triggers.Add(new InteractionPressableEntry() { eventID = InteractionPressableType.PointerClick, callback = interActionEvent }); touchableButton.Triggers.Add(new InteractionTouchableEntry() { eventID = InteractionTouchableType.PokePress, callback = interActionEvent }); } } protected virtual void OnNormalKeyClick(BaseEventData eventData) { TextMesh textMesh = this.GetComponentInChildren(); GameKey3Dboard gameKey3Dboard = this.GetComponentInParent(); gameKey3Dboard.OnNormalKeyClick(textMesh.text); } public void OnPointerExit(PointerEventData eventData) { this.GetComponentInChildren().material.color = color_Gray; } public void OnPointerEnter(PointerEventData eventData) { this.GetComponentInChildren().material.color = color_Blue; } public void OnPointerDown(PointerEventData eventData) { } public void OnPointerClick(PointerEventData eventData) { } public void OnPointerUp(PointerEventData eventData) { } public void OnDrag(PointerEventData eventData) { } }