Skip to content

Commit e278de0

Browse files
committed
simplified type creation
1 parent 413237e commit e278de0

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

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

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -206,29 +206,11 @@ 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+
new object[] { TrackingState.NotTracked, controllingHand, inputSource }) as GenericOpenVRController;
229211

230212
Debug.Assert(detectedController != null);
231-
detectedController?.SetupConfiguration(controllerType);
213+
detectedController.SetupConfiguration(controllerType);
232214

233215
for (int i = 0; i < detectedController?.InputSource?.Pointers?.Length; i++)
234216
{

0 commit comments

Comments
 (0)