MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Should add existing controllers to controllerDictionary in Awake instead of OnInteractionSouorceUpdated

Open timGerken opened this issue 9 years ago • 3 comments

After talking with @keveleigh , by "noticing" controllers in OnInteractionSourceUpdated, we try to add the same controller multiple times to the dictionary which causes a collections exception.

https://github.com/Microsoft/MixedRealityToolkit-Unity/blob/1ad7ffe208b2b2ed22bedee490ab69ba5128c584/Assets/HoloToolkit/Input/Scripts/Utilities/MotionControllerVisualizer.cs#L199

Instead, we should get all the controllers currently tracked from the InteractionManager and add them to the dictionary in Awake() and then rely on InteractionSourceDetected to notice any new controllers.

timGerken avatar Oct 18 '17 17:10 timGerken

via #1195

timGerken avatar Oct 18 '17 17:10 timGerken

This method still produces a single duplicate add if the script is in the scene at the start, since we'll be attempting an add in both the new loop and in the first SourceDetected event. I have an incoming PR which uses a loadingControllers list to keep track of any controllers that are in the process of being added.

keveleigh avatar Oct 18 '17 19:10 keveleigh

via #1196

keveleigh avatar Oct 18 '17 20:10 keveleigh