InteractableHoverEvents.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. //
  3. // Purpose: Sends UnityEvents for basic hand interactions
  4. //
  5. //=============================================================================
  6. using UnityEngine;
  7. using UnityEngine.Events;
  8. using System.Collections;
  9. namespace Valve.VR.InteractionSystem
  10. {
  11. //-------------------------------------------------------------------------
  12. [RequireComponent( typeof( Interactable ) )]
  13. public class InteractableHoverEvents : MonoBehaviour
  14. {
  15. public UnityEvent onHandHoverBegin;
  16. public UnityEvent onHandHoverEnd;
  17. public UnityEvent onAttachedToHand;
  18. public UnityEvent onDetachedFromHand;
  19. //-------------------------------------------------
  20. private void OnHandHoverBegin()
  21. {
  22. onHandHoverBegin.Invoke();
  23. }
  24. //-------------------------------------------------
  25. private void OnHandHoverEnd()
  26. {
  27. onHandHoverEnd.Invoke();
  28. }
  29. //-------------------------------------------------
  30. private void OnAttachedToHand( Hand hand )
  31. {
  32. onAttachedToHand.Invoke();
  33. }
  34. //-------------------------------------------------
  35. private void OnDetachedFromHand( Hand hand )
  36. {
  37. onDetachedFromHand.Invoke();
  38. }
  39. }
  40. }