Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves issue that causes numerous exceptions of the Focus Provider has not been configured. #143

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Runtime/Input/Interactables/InteractableCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ private void AssignWorldCanvasCamera()
{
if (ServiceManager.IsActiveAndInitialized &&
ServiceManager.Instance.TryGetService<IInputService>(out var inputService) &&
canvas.isRootCanvas && canvas.renderMode == RenderMode.WorldSpace)
canvas.isRootCanvas && canvas.renderMode == RenderMode.WorldSpace &&
inputService.FocusProvider != null)
{
canvas.worldCamera = inputService.FocusProvider.UIRaycastCamera;
}
Expand Down
5 changes: 5 additions & 0 deletions Runtime/Input/Interactors/GenericPointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public GenericPointer(string pointerName, IInputSource inputSourceParent)
{
if (ServiceManager.Instance.TryGetService<IInputService>(out var inputService))
{
if(inputService.FocusProvider == null)
{
throw new ArgumentException($"Couldn't find a valid {nameof(IFocusProvider)} configured for the {nameof(IInputService)}!");
FejZa marked this conversation as resolved.
Show resolved Hide resolved
}

PointerId = inputService.FocusProvider.GenerateNewPointerId();
PointerName = pointerName;
this.inputSourceParent = inputSourceParent;
Expand Down
6 changes: 3 additions & 3 deletions Runtime/Input/Modules/GazeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ protected virtual async void Start()
}

// We've been destroyed during the await.
if (this == null) { return; }
if (this == null || GazePointer == null) { return; }

lateInitialize = false;
InputService.Register(gameObject);
Expand Down Expand Up @@ -376,7 +376,7 @@ protected virtual void OnDisable()
{
InputService?.Unregister(gameObject);

if (GazePointer.BaseCursor != null)
if (GazePointer != null && GazePointer.BaseCursor != null)
{
GazePointer.BaseCursor.IsVisible = false;
}
Expand Down Expand Up @@ -434,7 +434,7 @@ void IInputHandler.OnInputDown(InputEventData eventData)

private IInteractor InitializeGazePointer()
{
if (InputService == null) { return null; }
if (InputService == null || InputService.FocusProvider == null) { return null; }

if (gazeTransform == null)
{
Expand Down