There is an issue where the switch statement does not work anymore and then Unity complains that another script is to blame for this exception. I don’t know why or how this error is occurring but it is stopping me from playing the build of the game inside the editor. The full error reads:
Unhandled Exception: System.StackOverflowException: The requested operation caused a stack overflow.
at Mono.CSharp.ExplicitBlock.EmitMeta (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
The script that has the switch statement with the error has only this inside:
switch(serialNumber)
{
case 0: break;
}
While the other script has thousands of cases (too many to put in this question), why is it complaining?
My speculation from what I am getting from this exception is that a switch statement can hold only so many cases, but if that was true, then how many cases can I put in a switch statement?
I am so confused on this, any help would be appreciated.
Update: When I comment out the line “case 0: break;” from the switch statement. I get this message:
Assets/Scripts/Database.cs(122,17): warning CS1522: Empty switch block
Unhandled Exception: System.StackOverflowException: The requested operation caused a stack overflow.
at Mono.CSharp.ExplicitBlock.EmitMeta (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0
Normally that would be a warning, but it shows it as an error and still prevents me from running the build in the editor.