Skip to content

Instantly share code, notes, and snippets.

@ciwolsey
Created August 7, 2019 06:29
Show Gist options
  • Save ciwolsey/7f20d2a6889f8bafb36e4b5ee3ec5151 to your computer and use it in GitHub Desktop.
Save ciwolsey/7f20d2a6889f8bafb36e4b5ee3ec5151 to your computer and use it in GitHub Desktop.
using Valve.VR;
using UnityEngine;
using UnityEngine.Events;
public class SteamVRBooleanToZinnia : MonoBehaviour {
public SteamVR_Action_Boolean SteamVR_Input_Action;
public SteamVR_Input_Sources Source;
[System.Serializable]
public class Changed : UnityEvent<bool> {}
public Changed Output;
private void Awake()
{
if (Output == null)
Output = new Changed();
}
private void OnEnable() {
SteamVR_Input_Action.onChange += InputSource_onChange;
}
private void OnDisable() {
SteamVR_Input_Action.onChange -= InputSource_onChange;
}
private void InputSource_onChange(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource, bool state) {
Output.Invoke(state);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment