IMHOTEP Framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
Interactable.cs
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 
7 using UnityEngine;
8 using UnityEngine.Events;
9 using System.Collections;
10 
11 namespace Valve.VR.InteractionSystem
12 {
13  //-------------------------------------------------------------------------
14  public class Interactable : MonoBehaviour
15  {
16  public delegate void OnAttachedToHandDelegate( Hand hand );
17  public delegate void OnDetachedFromHandDelegate( Hand hand );
18 
19  [HideInInspector]
20  public event OnAttachedToHandDelegate onAttachedToHand;
21  [HideInInspector]
22  public event OnDetachedFromHandDelegate onDetachedFromHand;
23 
24  //-------------------------------------------------
25  private void OnAttachedToHand( Hand hand )
26  {
27  if ( onAttachedToHand != null )
28  {
29  onAttachedToHand.Invoke( hand );
30  }
31  }
32 
33 
34  //-------------------------------------------------
35  private void OnDetachedFromHand( Hand hand )
36  {
37  if ( onDetachedFromHand != null )
38  {
39  onDetachedFromHand.Invoke( hand );
40  }
41  }
42  }
43 }