Last active
August 8, 2019 05:33
-
-
Save ciwolsey/5690259d59abb695871a367cd8f46a1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Valve.VR; | |
using UnityEngine; | |
using UnityEngine.Events; | |
public class SteamVRBooleanAction : MonoBehaviour | |
{ | |
public SteamVR_Action_Boolean InputAction; | |
public SteamVR_Input_Sources InputSource; | |
[System.Serializable] | |
public class Changed : UnityEvent<bool> {} | |
public Changed OutputAction; | |
private void Awake() | |
{ | |
if (OutputAction == null) | |
OutputAction = new Changed(); | |
} | |
private void OnEnable() | |
{ | |
InputAction[InputSource].onChange += OnChange; | |
} | |
private void OnDisable() | |
{ | |
InputAction[InputSource].onChange -= OnChange; | |
} | |
private void OnChange(SteamVR_Action_Boolean action, SteamVR_Input_Sources source, bool state) | |
{ | |
OutputAction.Invoke(state); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment