1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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<PressableButton>();
- TouchableButton touchableButton = this.GetComponent<TouchableButton>();
- 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<TextMesh>();
- GameKey3Dboard gameKey3Dboard = this.GetComponentInParent<GameKey3Dboard>();
- gameKey3Dboard.OnNormalKeyClick(textMesh.text);
- }
- public void OnPointerExit(PointerEventData eventData)
- {
- this.GetComponentInChildren<MeshRenderer>().material.color = color_Gray;
- }
- public void OnPointerEnter(PointerEventData eventData)
- {
- this.GetComponentInChildren<MeshRenderer>().material.color = color_Blue;
- }
- public void OnPointerDown(PointerEventData eventData)
- {
- }
- public void OnPointerClick(PointerEventData eventData)
- {
- }
- public void OnPointerUp(PointerEventData eventData)
- {
- }
- public void OnDrag(PointerEventData eventData)
- {
- }
- }
|