Created
August 7, 2019 06:29
-
-
Save ciwolsey/7f20d2a6889f8bafb36e4b5ee3ec5151 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 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