NibiruKeyBoardSingle.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. using UnityEngine.EventSystems;
  5. namespace Nxr.Internal
  6. {
  7. public class NibiruKeyBoardSingle : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
  8. {
  9. public Transform m_trsSelf;
  10. public Image m_imageKey;
  11. public Text m_textKey;
  12. public string m_strChar;
  13. public KeyBoardInfo m_CKeyBoardInfo = null;
  14. public BoxCollider m_colliderKey;
  15. // Use this for initialization
  16. void Awake()
  17. {
  18. m_trsSelf = this.transform;
  19. m_imageKey = m_trsSelf.GetComponent<Image>();
  20. m_textKey = m_trsSelf.GetComponentInChildren<Text>();
  21. m_colliderKey = m_trsSelf.GetComponent<BoxCollider>();
  22. m_colliderKey.enabled = false;
  23. }
  24. void Start()
  25. {
  26. // 怀疑是unity的bug,导致碰撞信息失效
  27. m_colliderKey.enabled = true;
  28. }
  29. public void OnPointerEnter(PointerEventData data)
  30. {
  31. //if((m_eKeyBoard)m_CKeyBoardInfo.m_bType == m_eKeyBoard.Add || (m_eKeyBoard)m_CKeyBoardInfo.m_bType == m_eKeyBoard.Space)
  32. m_imageKey.sprite = Resources.Load<Sprite>("KeyBoard/keyboard_letter_down");
  33. }
  34. public void OnPointerExit(PointerEventData data)
  35. {
  36. //if ((m_eKeyBoard)m_CKeyBoardInfo.m_bType == m_eKeyBoard.Add || (m_eKeyBoard)m_CKeyBoardInfo.m_bType == m_eKeyBoard.Space)
  37. m_imageKey.sprite = Resources.Load<Sprite>("KeyBoard/keyboard_letter_up");
  38. }
  39. }
  40. }