By fafase
on Mon, 01/26/2015 - 09:23
Vuforia SDK Version: 3.x -
Description with steps to reproduce:
Hei,
The following is happeing in Unity editor.
When trying to register two listeners to the RegisterTrackEventHandler, the first one goes fine but the second one thorws this on registration:
InvalidOperationException: Collection was modified; enumeration operation may not execute. System.Collections.Generic.List`1+Enumerator[ITrackableEventHandler].VerifyState () (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:778) System.Collections.Generic.List`1+Enumerator[ITrackableEventHandler].MoveNext () (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:784) TrackableBehaviour.OnTrackerUpdate (Status newStatus) DataSetTrackableBehaviour.OnTrackerUpdate (Status newStatus) StateManagerImpl.UpdateTrackablePoses (UnityEngine.Camera arCamera, .TrackableResultData[] trackableResultDataArray, Int32 originTrackableID, Int32 frameIndex) QCARManagerImpl.UpdateTrackers (FrameState frameState) QCARManagerImpl.Update (ScreenOrientation counterRotation) QCARAbstractBehaviour.Update ()
The code I am using is fairly straightoforward:
private void Init(bool register) { Debug.Log ("Registering LocalTrackTarget"); TrackableBehaviour trackableBehaviour = GetComponent<TrackableBehaviour>(); if (trackableBehaviour != null) { trackableBehaviour.RegisterTrackableEventHandler(this); } TouchInputManager.Instance.RegisterTrackableBehaviour(); }
And this is on the TouchInputManager:
public void RegisterTrackableBehaviour(){ Debug.Log("RegisterTrackableBehaviour"); TrackableBehaviour trackableBehaviour = FindObjectOfType<TrackableBehaviour>(); if (trackableBehaviour != null) { Debug.Log("RegisterTrackableBehaviour registered"); trackableBehaviour.RegisterTrackableEventHandler(this); } }
The input I get is
-
"Registering LocalTrackTarget"
-
"RegisterTrackableBehaviour"
-
"RegisterTrackableBehaviour registered"
- Exception is thrown
The exception is not showing up again but am I doing somethig wrong in there?
- Development OS (Mac OS X, Windows, Linux): Mac OS X - Unity - Mobile OS and Version: iOS 7 - Mobile Device Manufacturer and Model name: Apple iPhone - Do the Vuforia Sample Applications show the same behavior?: