Advertisement
Guest User

Untitled

a guest
Aug 10th, 2016
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.EventSystems;
  4.  
  5. public class MouseEnterScript : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
  6. {
  7. public void OnPointerEnter(PointerEventData eventData)
  8. {
  9. Debug.Log("Over Name: " + eventData.pointerCurrentRaycast.gameObject.name);
  10. Debug.Log("Over Tag: " + eventData.pointerCurrentRaycast.gameObject.tag);
  11. Debug.Log("Over GameObject: " + eventData.pointerCurrentRaycast.gameObject);
  12. mouseOver = true;
  13. gameObjectDetected = eventData.pointerCurrentRaycast.gameObject.name;
  14. }
  15.  
  16. public void OnPointerExit(PointerEventData eventData)
  17. {
  18. Debug.Log("Exit Name: " + eventData.pointerCurrentRaycast.gameObject.name);
  19. Debug.Log("Exit Tag: " + eventData.pointerCurrentRaycast.gameObject.tag);
  20. Debug.Log("Exit GameObject: " + eventData.pointerCurrentRaycast.gameObject);
  21. mouseOver = false;
  22. gameObjectDetected = eventData.pointerCurrentRaycast.gameObject.name;
  23. }
  24.  
  25. bool mouseOver = false;
  26. string gameObjectDetected = null;
  27.  
  28.  
  29. void Update()
  30. {
  31. if (mouseOver)
  32. {
  33. //Do something with gameObjectDetected
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement