Skip to content

Commit 8ad9f3b

Browse files
author
lawwong
committed
Fix not showing device in Unity 5.6 w/ SteamVR plugin v1.2.3
SteamVR v1.2.3 NewPosesUpdater doesn't work because OnCameraPreCull callback (called onc per camera e per frame) in Unity 5.6 seems doesn't report VR camera as CameraType.VR (CameraType.Game instead), and the updater skip them. After Unity 2017.2 updating VR device pose should use onBeforeRender callback instead (called once per frame) close #28
1 parent 0b322d4 commit 8ad9f3b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Assets/HTC.UnityPlugin/VRModule/VRModuleManager.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ private void ActivateModule(VRModuleActiveEnum module)
186186
{
187187
#if VIU_STEAMVR
188188
case VRModuleActiveEnum.SteamVR:
189-
#if VIU_STEAMVR_1_2_0_OR_NEWER
189+
#if VIU_STEAMVR_1_2_3_OR_NEWER && !UNITY_2017_1_OR_NEWER
190+
Camera.onPreCull += OnCameraPreCull;
191+
#elif VIU_STEAMVR_1_2_0_OR_NEWER
190192
SteamVR_Events.NewPoses.AddListener(OnSteamVRNewPose);
191193
#elif VIU_STEAMVR_1_1_1
192194
SteamVR_Utils.Event.Listen("new_poses", OnSteamVRNewPoseArgs);
@@ -226,7 +228,7 @@ private void OnCameraPreCull(Camera cam)
226228
var thisFrame = Time.frameCount;
227229
if (m_poseUpdatedFrame == thisFrame) { return; }
228230

229-
if (cam.cameraType != CameraType.Game) { return; }
231+
if (cam.cameraType != CameraType.Game && cam.cameraType != CameraType.VR) { return; }
230232

231233
m_poseUpdatedFrame = thisFrame;
232234
UpdateActiveModuleDeviceState();
@@ -303,7 +305,9 @@ private void DeactivateModule()
303305
{
304306
#if VIU_STEAMVR
305307
case VRModuleActiveEnum.SteamVR:
306-
#if VIU_STEAMVR_1_2_0_OR_NEWER
308+
#if VIU_STEAMVR_1_2_3_OR_NEWER && !UNITY_2017_1_OR_NEWER
309+
Camera.onPreCull -= OnCameraPreCull;
310+
#elif VIU_STEAMVR_1_2_0_OR_NEWER
307311
SteamVR_Events.NewPoses.RemoveListener(OnSteamVRNewPose);
308312
#elif VIU_STEAMVR_1_1_1
309313
SteamVR_Utils.Event.Remove("new_poses", OnSteamVRNewPoseArgs);

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/VIUVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ namespace HTC.UnityPlugin.Vive
66
{
77
public static class VIUVersion
88
{
9-
public static readonly Version current = new Version("1.8.0.8");
9+
public static readonly Version current = new Version("1.8.0.9");
1010
}
1111
}

0 commit comments

Comments
 (0)