using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class SCKeyboardKey : MonoBehaviour { 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); } }