Hi everyone
I'm on Unity 2020 and AC 1.70.1 (I can't upgrade due to my own expansions interfering with future versions)
I have a card game, removing from inventory always gives me this error:
InvalidOperationException: Collection was modified; enumeration operation may not execute.
System.ThrowHelper.ThrowInvalidOperationException (System.ExceptionResource resource) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Collections.Generic.List1+Enumerator[T].MoveNextRare () (at <695d1cc93cca45069c528c15c9fdd749>:0) System.Collections.Generic.List
1+Enumerator[T].MoveNext () (at <695d1cc93cca45069c528c15c9fdd749>:0)
AC.RuntimeInventory.Remove (System.Int32 _id, System.Int32 amount, System.Boolean setAmount, System.Collections.Generic.List`1[T] itemList) (at Assets/Plugins/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:2194)
AC.RuntimeInventory.Remove (System.Int32 _id, System.Int32 amount) (at Assets/Plugins/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:562)
AC.RuntimeInventory.Remove (System.String _name, System.Int32 amount) (at Assets/Plugins/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:650)
CheckCards.CheckCard () (at Assets/ActionLists/Card Actionlists/CheckCards.cs:42)
UnityEngine.Events.InvokableCall.Invoke () (at <6e07980a1f094265930cb1f27e7e3ec3>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <6e07980a1f094265930cb1f27e7e3ec3>:0)
AC.ActionEvent.Run () (at Assets/Plugins/AdventureCreator/Scripts/Actions/ActionEvent.cs:44)
AC.ActionList+d__34.MoveNext () (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:377)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <6e07980a1f094265930cb1f27e7e3ec3>:0)
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
AC.ActionList:ProcessAction(Int32) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:327)
AC.ActionList:BeginActionList(Int32, Boolean) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:294)
AC.ActionList:Interact(Int32, Boolean) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:195)
AC.ActionRunActionList:Run() (at Assets/Plugins/AdventureCreator/Scripts/Actions/ActionRunActionList.cs:136)
AC.d__34:MoveNext() (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:377)
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
AC.ActionList:ProcessAction(Int32) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:327)
AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:559)
AC.ActionList:EndAction(Action) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:477)
AC.d__34:MoveNext() (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:446)
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
AC.ActionList:ProcessAction(Int32) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:327)
AC.ActionList:ProcessActionEnd(ActionEnd, Int32, Boolean) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:559)
AC.ActionList:EndAction(Action) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:477)
AC.d__34:MoveNext() (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:446)
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
AC.ActionList:ProcessAction(Int32) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:327)
AC.RuntimeActionList:BeginActionList(Int32, Boolean) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:186)
AC.ActionList:Interact(Int32, Boolean) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/ActionList.cs:195)
AC.RuntimeActionList:DownloadActions(ActionListAsset, Conversation, Int32, Boolean, Boolean, Boolean) (at Assets/Plugins/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:141)
AC.AdvGame:RunActionListAsset(ActionListAsset, Conversation, Int32, Boolean, Boolean) (at Assets/Plugins/AdventureCreator/Scripts/Static/AdvGame.cs:252)
AC.AdvGame:RunActionListAsset(ActionListAsset, Int32, Int32) (at Assets/Plugins/AdventureCreator/Scripts/Static/AdvGame.cs:166)
AC.MenuButton:ProcessClick(Menu, Int32, MouseState) (at Assets/Plugins/AdventureCreator/Scripts/Menu/Menu classes/MenuButton.cs:652)
AC.MenuElement:ProcessClickUI(Menu, Int32, MouseState) (at Assets/Plugins/AdventureCreator/Scripts/Menu/Menu classes/MenuElement.cs:242)
AC.<>c__DisplayClass37_0:b__0() (at Assets/Plugins/AdventureCreator/Scripts/Menu/Menu classes/MenuElement.cs:209)
UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent()
AC.OptionalMouseInputModule:Process() (at Assets/Plugins/AdventureCreator/Scripts/Menu/OptionalMouseInputModule.cs:158)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)
So I tried to turn it into a script:
pastebin: https://pastebin.com/A4c1NUuJ
Same error occurred but now I'm dedicated to doing it via script lol. Is there a fix via RuntimeInventory.cs that I can use?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Have you modified AC's RuntimeInventory script? The line endings do not match my copy of v1.70.1.
Near the top of the protected Remove function, try replacing:
with: