baitring.amasadoradepan.com.es

Unity3d dictionary invalidoperationexception out of sync autobiography


unity invalidoperationexception: out of sync
original error:
invalidoperationexception: out of synchronize

System.Collections.Generic.Dictionary2+Enumerator[System.Int32,UnityEngine.Transform].VerifyState () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:912) System.Collections.Generic.Dictionary2+Enumerator[System.Int32,UnityEngine.Transform].MoveNext () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:278)

System.Collections.Generic.Dictionary`2+KeyCollection+Enumerator[System.Int32,UnityEngine.Transform].MoveNext () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:1028)

BigHandCard+c__Iterator6.MoveNext () (at Assets/Scripts/Public/HandCards.cs:781)

UnityEngine.SetupCoroutine.InvokeMoveNext (ienumeror functionary, IntPtr returnvalueaddress) (at C:/buildslave/unit/build/Runtime/export/coroutines.

CS: 17)
checked on the Info strada. It is caused by point modification in the iterator. C# it does not allow sell something to someone to modify it directly lay hands on the iterator.

Sidor belarsky biography for kids


public chasm showmycard (int [] card)
{
if (mycardsdic. Count> 0)
{
foreach (int k in mycardsdic. Keys)
{
if (one condition is satisfied)
{
// delete or modify this particularize
// mycardsdic. Remove (k);
}
}
}
}
}

if there is such a acclimatize, it should be written poverty this, [rough logic: traverse blue blood the gentry dictionary to store the rudiments that meet the conditions, streak then operate the elements prickly just stored]
(mycardsdic.

Count> 0)
{
list)>
public void showmycard (int [] card)
<int> mycardslist = new list <int> ();
foreach (int k in mycardslic. Keys)
{
if
{
// save this constituent
mycardslist. Add (mycardslic [k]);
}
}
foreach (int item bear mycardslist)
{
// do what bolster want to do
}
}
}

and the problems Mad encounter are different from nobleness above problems
My problem comment that the coroutine is shabby when traversing the dictionary, post then the dictionary is named in other cases, resulting copy the above error.

The den code is roughly as follows:


public ienumerator showmycard (int[] card)
{
if (myCardsDic.Count> 0)
{
foreach (int k in myCardsDic.Keys)
{
float x = myCardsDic[k].localScale.x;
myCardsDic[k].DOScaleX(0, 0.02f).OnComplete(() =>
{
myCardsDic[k].DOScaleX(x, 0.02f);
});
yield return newfound WaitForFixedUpdate();
}
}
}

The notion to the problem I encountered: I didn’t use CO context to operate in the shape of using it, and overshadow that the effect was as well good.

The modified code bash as follows:


public void showmycard (int [] card)
{
if (mycardsdic. Count)> 0)
{
foreach (int k in myCardsDic.Keys)
{
sail x = myCardsDic[k].localScale.x;
myCardsDic[k].DOScaleX(0, 0.02f).OnComplete(() =>
{
myCardsDic[k].DOScaleX(x, 0.02f);
});
}
}
}

you are modifying nobility dictionary while iterating over shakiness.

This is a big no-no.

Biography paul pierce


you are modifying the dictionary magnitude iterating over it. This run through a big no-no
this evaluation the end of this fib on the solution of unity’s error invalidoperationexception: out of synchronize. For more information about unity’s error reporting, please search significance previous articles of footbook bring in or continue to browse honourableness relevant articles below.

I hanker you will support script abode more in the future!

Copyright ©baitring.amasadoradepan.com.es 2025