@@ -99,44 +99,43 @@ public bool SetupConfiguration(Type controllerType)
9999 var controllerMappings = MixedRealityToolkit . Instance . ActiveProfile . InputSystemProfile . ControllerMappingProfile . MixedRealityControllerMappingProfiles ;
100100
101101 // Have to test that a controller type has been registered in the profiles,
102- // else it's Unity Input manager mappings will not have been setup by the inspector
102+ // else its Unity Input manager mappings will not have been set up by the inspector.
103103 bool profileFound = false ;
104104
105105 for ( int i = 0 ; i < controllerMappings ? . Length ; i ++ )
106106 {
107- if ( ! profileFound && controllerMappings [ i ] . ControllerType . Type == controllerType )
107+ if ( controllerMappings [ i ] . ControllerType . Type == controllerType )
108108 {
109109 profileFound = true ;
110- }
111-
112- // Assign any known interaction mappings.
113- if ( controllerMappings [ i ] . ControllerType . Type == controllerType &&
114- controllerMappings [ i ] . Handedness == ControllerHandedness &&
115- controllerMappings [ i ] . Interactions . Length > 0 )
116- {
117- MixedRealityInteractionMapping [ ] profileInteractions = controllerMappings [ i ] . Interactions ;
118- MixedRealityInteractionMapping [ ] newInteractions = new MixedRealityInteractionMapping [ profileInteractions . Length ] ;
119110
120- for ( int j = 0 ; j < profileInteractions . Length ; j ++ )
111+ // If it is an exact match, assign interaction mappings.
112+ if ( controllerMappings [ i ] . Handedness == ControllerHandedness &&
113+ controllerMappings [ i ] . Interactions . Length > 0 )
121114 {
122- newInteractions [ j ] = new MixedRealityInteractionMapping ( profileInteractions [ j ] ) ;
123- }
115+ MixedRealityInteractionMapping [ ] profileInteractions = controllerMappings [ i ] . Interactions ;
116+ MixedRealityInteractionMapping [ ] newInteractions = new MixedRealityInteractionMapping [ profileInteractions . Length ] ;
117+
118+ for ( int j = 0 ; j < profileInteractions . Length ; j ++ )
119+ {
120+ newInteractions [ j ] = new MixedRealityInteractionMapping ( profileInteractions [ j ] ) ;
121+ }
124122
125- AssignControllerMappings ( newInteractions ) ;
126- break ;
123+ AssignControllerMappings ( newInteractions ) ;
124+ break ;
125+ }
127126 }
127+ }
128+
129+ // If no controller mappings found, warn the user. Does not stop the project from running.
130+ if ( Interactions == null || Interactions . Length < 1 )
131+ {
132+ SetupDefaultInteractions ( ControllerHandedness ) ;
128133
129- // If no controller mappings found, warn the user. Does not stop the project from running.
134+ // We still don't have controller mappings, so this may be a custom controller.
130135 if ( Interactions == null || Interactions . Length < 1 )
131136 {
132- SetupDefaultInteractions ( ControllerHandedness ) ;
133-
134- // We still don't have controller mappings, so this may be a custom controller.
135- if ( Interactions == null || Interactions . Length < 1 )
136- {
137- Debug . LogWarning ( $ "No Controller interaction mappings found for { controllerMappings [ i ] . Description } .") ;
138- return false ;
139- }
137+ Debug . LogWarning ( $ "No Controller interaction mappings found for { controllerType } .") ;
138+ return false ;
140139 }
141140 }
142141
0 commit comments