Skip to content

XRSDKDeviceManager can no longer create GenericXRSDKControllers as a fallback #10200

@robbbbbb

Description

@robbbbbb

Describe the bug

If XRSDKDeviceManager attempts to create an instance of the base GenericXRSDKControllers class it will fail as the invocation of Activator.CreateInstance no longer passes the correct number of arguments.

This occurs because GenericXRSDKController's constructor now takes 5 arguments, but all of its base classes still take only 4.

Because all subclasses of XRSDKDeviceManager (e.g. OculusXRSDKDeviceManager, WindowsMixedRealityDeviceManager, etc.) pass back a subclass of GenericXRSDKController from their GetControllerType() function, this never occurs with the default MRTK setup.

But subclasses of XRSDKDeviceManager which do not override GetControllerType() will fail on the subsequent Activator.CreateInstance call in GetOrAddController()

To reproduce

Steps to reproduce the behavior:

  1. Create a subclass of XRSDKDeviceManager without overriding GetOrAddController or GetControllerType
  2. Set that subclass as an input provider in the profile's input system settings with a Supported Platform of 'Windows Universal' (or whatever platform you deploy to)
  3. Add right and a left hand 'Generic Unity' controllers to the Controller Definitions list in the Input profile's Controllers section
  4. Build to device and run

Expected behavior

The controllers are detected (either hands or VR controllers) and the default implementations for tracking and interactions in GenericXRSDKController are used.

Actual behaviour

The controllers are not detected due to a MissingMethodException thrown at the invocation to Activator.CreateInstance

To fix

Either:

  1. Change the Activator.CreateInstance call and the constructors in the subclasses or
  2. Switch on the controller type being created and call one overload or the other

Setup

  • Unity Version 2020.3.16f1
  • MRTK Version 2.7.2

Target platform (please complete the following information)

  • HoloLens 2
  • Oculus Quest 2
  • Vive Focus

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions