Skip to content

Commit 2e1e3c7

Browse files
author
ChengNan Yang
committed
Fix missing controller models after suspend/resume
1 parent 0c978eb commit 2e1e3c7

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

Assets/HTC.UnityPlugin/VRModule/Modules/UnityXRModuleBase.cs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,6 @@ public sealed override void BeforeRenderUpdate()
145145

146146
FlushDeviceState();
147147

148-
// mark all devices as disconnected
149-
// therefore, if a device should stay alive in this frame
150-
// should be set as connected in the next stage
151-
deviceIndex = 0u;
152-
for (var len = GetDeviceStateLength(); deviceIndex < len; ++deviceIndex)
153-
{
154-
if (TryGetValidDeviceState(deviceIndex, out prevState, out currState))
155-
{
156-
currState.isConnected = false;
157-
}
158-
}
159-
160148
InputDevices.GetDevices(connectedDevices);
161149

162150
foreach (var device in connectedDevices)
@@ -239,24 +227,24 @@ public sealed override void BeforeRenderUpdate()
239227
{
240228
if (prevDeviceConnected[i] && !currDeviceConnected[i])
241229
{
242-
if (indexMap.IsMapped(deviceIndex))
230+
if (indexMap.IsMapped(i))
243231
{
244-
indexMap.UnmapByIndex(deviceIndex);
232+
indexMap.UnmapByIndex(i);
245233
}
246234
else
247235
{
248-
Debug.LogWarning("[UnityXRModule] Disconnected device[" + deviceIndex + "] already unmapped");
236+
Debug.LogWarning("[UnityXRModule] Disconnected device[" + i + "] already unmapped");
249237
}
250238

251-
if (TryGetValidDeviceState(deviceIndex, out prevState, out currState) && currState.isConnected)
239+
if (TryGetValidDeviceState(i, out prevState, out currState) && currState.isConnected)
252240
{
253241
currState.Reset();
254-
if (uxrRightIndex == deviceIndex) { uxrRightIndex = INVALID_DEVICE_INDEX; }
255-
if (uxrLeftIndex == deviceIndex) { uxrLeftIndex = INVALID_DEVICE_INDEX; }
242+
if (uxrRightIndex == i) { uxrRightIndex = INVALID_DEVICE_INDEX; }
243+
if (uxrLeftIndex == i) { uxrLeftIndex = INVALID_DEVICE_INDEX; }
256244
}
257245
else
258246
{
259-
Debug.LogWarning("[UnityXRModule] Disconnected device[" + deviceIndex + "] already been reset");
247+
Debug.LogWarning("[UnityXRModule] Disconnected device[" + i + "] already been reset");
260248
}
261249
}
262250
}

0 commit comments

Comments
 (0)