Closed mistergreen closed 4 years ago
What's an ARWorldMapAddressable
? That isn't part of ARFoundation -- it looks like something has subscribed to the ARAnchorManager
's anchorsChanged
event and the error is in that method.
oh, thanks. I'm blind. ARWorldMapAddressable is my script controlling anchors. I was told to use anchor pending in dealing with anchorsChanged but I guess it's addressing an anchor that doesn't exist yet.
private void OnAchorAdded(ARAnchorsChangedEventArgs obj)
{
try
{
bool pending = obj.added[0].pending;
// need to figure out when adding by hand or when add on load
if (pending == false)
{
if (newTank)
{
PlaceTank(placementIndicator, obj.added[0]);
}
else
{
//load from file
//LoadObject(obj.added[0].trackableId);
for(int i=0; i < obj.added.Count; i++)
{
LoadObject(obj.added[i]);
}
}
}
}
catch (IOException error)
{
Debug.Log("+++ error: " + error.Message);
}
}
The ARAnchor
and associated GameObject
exist immediately. The pending
flag just determines whether or not the underlying AR framework has actually picked it up and started tracking it.
Your OnAnchorAdded
appears to subscribe to anchorsChanged
, which will be invoked whenever
So it's quite possible that an existing anchor got updated, and you tried to access element 0 of obj.added
, which would have no elements in it, hence the ArgumentOutOfRangeException
.
Thanks. I'll check obj.added.Count > 0 before accessing.
Cool. Can we close this issue?
Does any know what this error is? I get it on iOS 13.x, Unity 2019.3.x, ARfoundation 3.x It randomly pops up once in a while so it's hard report it as a bug.