SCKeyboardKey.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. public class SCKeyboardKey : MonoBehaviour
  6. {
  7. protected virtual void OnEnable()
  8. {
  9. }
  10. protected virtual void Start()
  11. {
  12. RegistKey();
  13. }
  14. protected virtual void RegistKey()
  15. {
  16. PressableButton pressableButton = this.GetComponent<PressableButton>();
  17. TouchableButton touchableButton = this.GetComponent<TouchableButton>();
  18. if (pressableButton && touchableButton)
  19. {
  20. InteractionEvent interActionEvent = new InteractionEvent();
  21. interActionEvent.AddListener(OnNormalKeyClick);
  22. pressableButton.Triggers.Add(new InteractionPressableEntry() { eventID = InteractionPressableType.PointerClick, callback = interActionEvent });
  23. touchableButton.Triggers.Add(new InteractionTouchableEntry() { eventID = InteractionTouchableType.PokePress, callback = interActionEvent });
  24. }
  25. }
  26. protected virtual void OnNormalKeyClick(BaseEventData eventData)
  27. {
  28. TextMesh textMesh = this.GetComponentInChildren<TextMesh>();
  29. GameKey3Dboard gameKey3Dboard = this.GetComponentInParent<GameKey3Dboard>();
  30. gameKey3Dboard.OnNormalKeyClick(textMesh.text);
  31. }
  32. }