[TrackedControllerFix] Slight cleanup for consistancy with SmoothRay.

TrackedControllerFix must do stuff in Awake so SmoothRay can handle the SteamVRTrackedObject in Start.
This commit is contained in:
NotAKidoS 2023-06-14 20:07:55 -05:00
parent 36b1323996
commit 62c5eec71a
2 changed files with 4 additions and 10 deletions

View file

@ -10,11 +10,7 @@ class PlayerSetupPatches
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Start))] [HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Start))]
static void Post_PlayerSetup_Start(ref PlayerSetup __instance) static void Post_PlayerSetup_Start(ref PlayerSetup __instance)
{ {
var leftFixer = __instance.vrLeftHandTracker.AddComponent<TrackedControllerFixer>(); __instance.vrLeftHandTracker.AddComponent<TrackedControllerFixer>().inputSource = SteamVR_Input_Sources.LeftHand;
leftFixer.inputSource = SteamVR_Input_Sources.LeftHand; __instance.vrRightHandTracker.AddComponent<TrackedControllerFixer>().inputSource = SteamVR_Input_Sources.RightHand;
leftFixer.Initialize();
var rightFixer = __instance.vrRightHandTracker.AddComponent<TrackedControllerFixer>();
rightFixer.inputSource = SteamVR_Input_Sources.RightHand;
rightFixer.Initialize();
} }
} }

View file

@ -11,10 +11,10 @@ public class TrackedControllerFixer : MonoBehaviour
SteamVR_TrackedObject trackedObject; SteamVR_TrackedObject trackedObject;
SteamVR_Behaviour_Pose oldBehaviourPose; SteamVR_Behaviour_Pose oldBehaviourPose;
SteamVR_Action_Pose actionPose; SteamVR_Action_Pose actionPose;
SteamVR_RenderModel renderModel; SteamVR_RenderModel renderModel;
public void Initialize() void Awake()
{ {
trackedObject = gameObject.AddComponent<SteamVR_TrackedObject>(); trackedObject = gameObject.AddComponent<SteamVR_TrackedObject>();
oldBehaviourPose = gameObject.GetComponent<SteamVR_Behaviour_Pose>(); oldBehaviourPose = gameObject.GetComponent<SteamVR_Behaviour_Pose>();
@ -46,9 +46,7 @@ public class TrackedControllerFixer : MonoBehaviour
void Update() void Update()
{ {
if (deviceIndex < 0) if (deviceIndex < 0)
{
CheckDeviceIndex(); CheckDeviceIndex();
}
} }
void OnDeviceConnectedChanged(SteamVR_Action_Pose changedAction, SteamVR_Input_Sources changedSource, bool connected) void OnDeviceConnectedChanged(SteamVR_Action_Pose changedAction, SteamVR_Input_Sources changedSource, bool connected)