"Komatsu teaches you to develop" "Unity practical Skills" Invalidoperationexception:out of sync

Source: Internet
Author: User

This bug appears in unity development.

The online check is caused by direct modification in the iterator. C # is not allowing you to modify directly in an iterator.

Changed a bit to really solve.

That's what it was.

[CSharp]View PlainCopy 
    1. Public void Run ()
    2. {
    3. foreach (var item in timerdict)
    4. {
    5. if (null! = Item. Value)
    6. {
    7. Item. Value.run ();
    8. }
    9. }
    10. }


Change to this:

[CSharp]View PlainCopy 
    1. Public void Run ()
    2. {
    3. //When using iterators, you cannot directly modify the values in the inside, get references in the operation
    4. Temptimerlist.clear ();
    5. foreach (Ctimeritem item in timerdict.values)
    6. {
    7. if (null! = Item)
    8. {
    9. Temptimerlist.add (item);
    10. }
    11. }
    12. For (int i =0;i<temptimerlist.count;i++)
    13. {
    14. Temptimerlist[i]. Run ();
    15. }
    16. }

"Komatsu teaches you to develop" "Unity practical Skills" Invalidoperationexception:out of sync

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.