PointerShine.cs 804 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.EventSystems;
  6. [RequireComponent(typeof(Image))]
  7. public class PointerShine : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
  8. {
  9. public Color EnterColor;
  10. public Color ExitColor;
  11. public Image image
  12. {
  13. get
  14. {
  15. return GetComponent<Image>();
  16. }
  17. }
  18. private void OnEnable()
  19. {
  20. image.color = ExitColor;// new Color32(58, 58, 58,255);
  21. }
  22. public void OnPointerEnter(PointerEventData eventData)
  23. {
  24. image.color = EnterColor;// new Color32(94, 94, 94, 255);
  25. }
  26. public void OnPointerExit(PointerEventData eventData)
  27. {
  28. image.color = ExitColor;// new Color32(58, 58, 58,255);
  29. }
  30. }