I have an event which several functions are subscribed to, two of which cause problems.
Function A removes target item from a Dictionary and then loops through all items and invokes IEnumerator which lerps them into their new position.
Function B is on the item itself. The item is faded out and then deleted.
However only after a single step of fade-out I get following message:
Collection was modified; enumeration operation may not execute.
It probably has something to do with that Function A removing the item from the Dictionary.
What are some direct workarounds for this? This is just a temporary script which is meant to do the job, its not a long-term solution. I could just pass the variable as parameter but that would add an ugly exception to rather clean codebase I have which could be a headache in the future.