I ran onto a strange bug this week... in my code, I'm using a `Queue<KeyValuePair>` to store a type of ennemy(string) and how many I need to spawn(int).
If I'm trying to something like :
list<string> aList = new list<string>();
aList[0] = aQueue.Dequeue().Key;
This code works in the editor, but not in the build.(Building for PC)
In fact, the line where I dequeue and everything after is not executed in the build.
The wierd thing is that everything before this line is executed...
I placed a GUIText that changes his text to debug this in the build....so I know that it is this exact line.
No errors, no warnings in the console.
Very weird.
Is there any complex data structure that Unity can't handle ?
I know this is a very old thread but I had this problem too.
if you go into monodevelop and go to Run >> Exceptions you can add exception types to the list of exceptions. this will catch the exception in the editor and make it easier to debug…
But, in a nut shell you need to check the queue count before accessing it. Even .Peek() will throw an exception if your queue is empty- which makes very little sense in my opinion. If it returned null at least you would get a null exception when you tried to dequeue which is far more useful…
I have the same problem too, inside the editor everything works fine but inside Xcode I got the this message:
InvalidOperationException: Operation is not valid due to the current state of the object
at System.Collections.Generic.Queue1[System.Single].Peek () [0x0000b] in /Applications/buildAgent/work/51c26656ff47b7e8/mcs/class/System/System.Collections.Generic/Queue.cs:154 at System.Collections.Generic.Queue1[System.Single].Dequeue () [0x00000] in /Applications/buildAgent/work/51c26656ff47b7e8/mcs/class/System/System.Collections.Generic/Queue.cs:138