When we built our game to a .exe and ran it some of the public variables set in scripts were not correct values. For example…
public bool DoDebug = false;
which could be checkboxed in the editor, was flipped.
We found there was a corrupt mainData file in the build data area.
Turns out we had another public volatile bool variable.
That messes Unity up completely.
The specific error in the development build (check the checkbox in the build for development mode) was…
The file '[build_dir]/[exe_name]_Data/mainData' is corrupted! Remove it and launch unity again!
[Position out of bounds! XXXXX > YYYYY]
Note: volatile is a keyword in C# that tells the compiler to not optimize variable access out. This lets us set debugger break points reliably.