Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. //
  3. // Purpose: This object will get hover events and can be attached to the hands
  4. //
  5. //=============================================================================
  6. using UnityEngine;
  7. using UnityEngine.Events;
  8. using System.Collections;
  9. namespace Valve.VR.InteractionSystem
  10. {
  11. //-------------------------------------------------------------------------
  12. public class Interactable : MonoBehaviour
  13. {
  14. public delegate void OnAttachedToHandDelegate( Hand hand );
  15. public delegate void OnDetachedFromHandDelegate( Hand hand );
  16. [HideInInspector]
  17. public event OnAttachedToHandDelegate onAttachedToHand;
  18. [HideInInspector]
  19. public event OnDetachedFromHandDelegate onDetachedFromHand;
  20. //-------------------------------------------------
  21. private void OnAttachedToHand( Hand hand )
  22. {
  23. if ( onAttachedToHand != null )
  24. {
  25. onAttachedToHand.Invoke( hand );
  26. }
  27. }
  28. //-------------------------------------------------
  29. private void OnDetachedFromHand( Hand hand )
  30. {
  31. if ( onDetachedFromHand != null )
  32. {
  33. onDetachedFromHand.Invoke( hand );
  34. }
  35. }
  36. }
  37. }