Skip to content

Commit 7d0e6fd

Browse files
Merge pull request #2550 from Jarodshow/mrtk_development
Simplified type creation
2 parents 413237e + 5f61059 commit 7d0e6fd

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

Assets/MixedRealityToolkit/_Core/Devices/OpenVR/OpenVRDeviceManager.cs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -206,26 +206,8 @@ private GenericOpenVRController GetOrAddController(XRNodeState xrNodeState)
206206
var pointers = RequestPointers(controllerType, controllingHand);
207207
var inputSource = InputSystem?.RequestNewGenericInputSource($"{CurrentControllerType} Controller {controllingHand}", pointers);
208208

209-
GenericOpenVRController detectedController = null;
210-
211-
switch (CurrentControllerType)
212-
{
213-
case SupportedControllerType.GenericOpenVR:
214-
detectedController = new GenericOpenVRController(TrackingState.NotTracked, controllingHand, inputSource);
215-
break;
216-
case SupportedControllerType.ViveWand:
217-
detectedController = new ViveWandController(TrackingState.NotTracked, controllingHand, inputSource);
218-
break;
219-
case SupportedControllerType.ViveKnuckles:
220-
detectedController = new ViveKnucklesController(TrackingState.NotTracked, controllingHand, inputSource);
221-
break;
222-
case SupportedControllerType.OculusTouch:
223-
detectedController = new OculusTouchController(TrackingState.NotTracked, controllingHand, inputSource);
224-
break;
225-
case SupportedControllerType.OculusRemote:
226-
detectedController = new OculusRemoteController(TrackingState.NotTracked, controllingHand, inputSource);
227-
break;
228-
}
209+
GenericOpenVRController detectedController = Activator.CreateInstance(controllerType,
210+
TrackingState.NotTracked, controllingHand, inputSource, null) as GenericOpenVRController;
229211

230212
Debug.Assert(detectedController != null);
231213
detectedController?.SetupConfiguration(controllerType);

0 commit comments

Comments
 (0)