12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- public class SCKeyboardKey : MonoBehaviour, IPointerHandler
- {
- private Color color_Gray = new Color32(48,48,48,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)
- {
- }
- }
|