Skip to content

Commit c7f6285

Browse files
author
David Kline
authored
Merge pull request #2695 from StephenHodgson/vNEXT-FocusProviderFix
Focus Provider Registration Fix
2 parents cabf74d + 133e08e commit c7f6285

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

Assets/MixedRealityToolkit-SDK/Features/Input/FocusProvider.cs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ private void Awake()
231231
"To create a UIRaycastCamera in your scene, find this Focus Provider GameObject and add one there.");
232232
CreateUiRaycastCamera();
233233
}
234+
235+
foreach (var inputSource in InputSystem.DetectedInputSources)
236+
{
237+
RegisterPointers(inputSource);
238+
}
234239
}
235240

236241
private void Update()
@@ -432,6 +437,23 @@ public bool RegisterPointer(IMixedRealityPointer pointer)
432437
return true;
433438
}
434439

440+
private void RegisterPointers(IMixedRealityInputSource inputSource)
441+
{
442+
// If our input source does not have any pointers, then skip.
443+
if (inputSource.Pointers == null) { return; }
444+
445+
for (int i = 0; i < inputSource.Pointers.Length; i++)
446+
{
447+
RegisterPointer(inputSource.Pointers[i]);
448+
449+
// Special Registration for Gaze
450+
if (inputSource.SourceId == InputSystem.GazeProvider.GazeInputSource.SourceId && gazeProviderPointingData == null)
451+
{
452+
gazeProviderPointingData = new PointerData(inputSource.Pointers[i]);
453+
}
454+
}
455+
}
456+
435457
/// <inheritdoc />
436458
public bool UnregisterPointer(IMixedRealityPointer pointer)
437459
{
@@ -816,30 +838,13 @@ private void UpdateFocusedObjects()
816838

817839
#region ISourceState Implementation
818840

841+
/// <inheritdoc />
819842
public void OnSourceDetected(SourceStateEventData eventData)
820843
{
821-
// If our input source does not have any pointers, then skip.
822-
if (eventData.InputSource.Pointers == null) { return; }
823-
824-
for (var i = 0; i < eventData.InputSource.Pointers.Length; i++)
825-
{
826-
RegisterPointer(eventData.InputSource.Pointers[i]);
827-
828-
// Special Registration for Gaze
829-
if (eventData.InputSource.SourceId == InputSystem.GazeProvider.GazeInputSource.SourceId)
830-
{
831-
Debug.Assert(gazeProviderPointingData == null, "Gaze Provider Pointer Data was already registered!");
832-
833-
if (gazeProviderPointingData == null)
834-
{
835-
gazeProviderPointingData = new PointerData(eventData.InputSource.Pointers[i]);
836-
}
837-
838-
Debug.Assert(gazeProviderPointingData != null);
839-
}
840-
}
844+
RegisterPointers(eventData.InputSource);
841845
}
842846

847+
/// <inheritdoc />
843848
public void OnSourceLost(SourceStateEventData eventData)
844849
{
845850
// If the input source does not have pointers, then skip.

0 commit comments

Comments
 (0)