diff --git a/OSVR-Unity/Assets/OSVRUnity/Sample/Scripts/SampleButtonScript.cs b/OSVR-Unity/Assets/OSVRUnity/Sample/Scripts/SampleButtonScript.cs
index 6f3c767..416bfc9 100644
--- a/OSVR-Unity/Assets/OSVRUnity/Sample/Scripts/SampleButtonScript.cs
+++ b/OSVR-Unity/Assets/OSVRUnity/Sample/Scripts/SampleButtonScript.cs
@@ -19,6 +19,7 @@
///
using UnityEngine;
+using UnityEngine.Events;
using System.Collections;
///
@@ -29,6 +30,9 @@
///
public class SampleButtonScript : OSVR.Unity.InterfaceBase
{
+ public UnityEvent OnPress;
+ public UnityEvent OnRelease;
+
void Start()
{
osvrInterface.RegisterCallback(handleButton);
@@ -37,5 +41,7 @@ void Start()
void handleButton(string path, bool state)
{
Debug.Log("Got button: " + path + " state is " + state);
+ if(state) OnPress.Invoke();
+ else OnRelease.Invoke();
}
}
diff --git a/OSVR-Unity/Assets/OSVRUnity/Sample/scripts/HandleButtonPress.cs b/OSVR-Unity/Assets/OSVRUnity/Sample/scripts/HandleButtonPress.cs
index d2c5261..7f742e9 100644
--- a/OSVR-Unity/Assets/OSVRUnity/Sample/scripts/HandleButtonPress.cs
+++ b/OSVR-Unity/Assets/OSVRUnity/Sample/scripts/HandleButtonPress.cs
@@ -19,6 +19,7 @@
///
using UnityEngine;
+using UnityEngine.Events;
using System.Collections;
///
@@ -27,6 +28,9 @@
[RequireComponent(typeof(OSVR.Unity.InterfaceGameObject))]
public class HandleButtonPress : MonoBehaviour
{
+ public UnityEvent OnPress;
+ public UnityEvent OnRelease;
+
public void Start()
{
gameObject.GetComponent().osvrInterface.RegisterCallback(handleButton);
@@ -35,5 +39,7 @@ public void Start()
public void handleButton(string path, bool state)
{
Debug.Log("Got button: " + path + " state is " + state);
+ if(state) OnPress.Invoke();
+ else OnRelease.Invoke();
}
}