[TrackedControllerFix] fix overlay issue

This commit is contained in:
NotAKidoS 2023-05-21 23:34:36 -05:00
parent c05213d970
commit 730ff58adc

View file

@ -10,18 +10,22 @@ public class TrackedControllerFixer : MonoBehaviour
SteamVR_TrackedObject trackedObject;
SteamVR_Behaviour_Pose oldBehaviourPose;
SteamVR_Action_Pose actionPose = SteamVR_Input.GetAction<SteamVR_Action_Pose>("Pose", false);
SteamVR_Action_Pose actionPose;
public void Initialize()
{
trackedObject = gameObject.AddComponent<SteamVR_TrackedObject>();
oldBehaviourPose = gameObject.GetComponent<SteamVR_Behaviour_Pose>();
oldBehaviourPose.broadcastDeviceChanges = false; //this fucks us
oldBehaviourPose.enabled = false;
actionPose = SteamVR_Input.GetAction<SteamVR_Action_Pose>("Pose", false);
if (actionPose != null) CheckDeviceIndex();
}
void OnEnable()
{
// DesktopVRSwitch support
if (actionPose != null) actionPose[inputSource].onDeviceConnectedChanged += OnDeviceConnectedChanged;
if (oldBehaviourPose != null)
oldBehaviourPose.enabled = false;
@ -29,6 +33,7 @@ public class TrackedControllerFixer : MonoBehaviour
void OnDisable()
{
// DesktopVRSwitch support
if (actionPose != null) actionPose[inputSource].onDeviceConnectedChanged -= OnDeviceConnectedChanged;
if (oldBehaviourPose != null)
oldBehaviourPose.enabled = true;
@ -43,7 +48,7 @@ public class TrackedControllerFixer : MonoBehaviour
void CheckDeviceIndex()
{
if (actionPose[inputSource].active && actionPose[inputSource].deviceIsConnected)
if (actionPose[inputSource].deviceIsConnected)
{
int trackedDeviceIndex = (int)actionPose[inputSource].trackedDeviceIndex;
if (deviceIndex != trackedDeviceIndex)