Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnityEvents for button press and release #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/// </copyright>

using UnityEngine;
using UnityEngine.Events;
using System.Collections;

/// <summary>
Expand All @@ -29,6 +30,9 @@
/// </summary>
public class SampleButtonScript : OSVR.Unity.InterfaceBase
{
public UnityEvent OnPress;
public UnityEvent OnRelease;

void Start()
{
osvrInterface.RegisterCallback(handleButton);
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/// </copyright>

using UnityEngine;
using UnityEngine.Events;
using System.Collections;

/// <summary>
Expand All @@ -27,6 +28,9 @@
[RequireComponent(typeof(OSVR.Unity.InterfaceGameObject))]
public class HandleButtonPress : MonoBehaviour
{
public UnityEvent OnPress;
public UnityEvent OnRelease;

public void Start()
{
gameObject.GetComponent<OSVR.Unity.InterfaceGameObject>().osvrInterface.RegisterCallback(handleButton);
Expand All @@ -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();
}
}