EnterExitImageChange.cs 649 B

12345678910111213141516171819202122232425262728
  1. using UnityEngine;
  2. using UnityEngine.EventSystems;
  3. using UnityEngine.UI;
  4. /// <summary>
  5. /// 鼠标进出图片切换
  6. /// </summary>
  7. public class EnterExitImageChange : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
  8. {
  9. public Sprite PointerEnterSprite;
  10. public Sprite PointerExitSprite;
  11. public Image mImage;
  12. public void OnPointerEnter(PointerEventData eventData)
  13. {
  14. mImage.sprite = PointerEnterSprite;
  15. }
  16. public void OnPointerExit(PointerEventData eventData)
  17. {
  18. mImage.sprite = PointerExitSprite;
  19. }
  20. public void BtnClickExecute()
  21. {
  22. mImage.sprite = PointerExitSprite;
  23. }
  24. }