Potential glitch in build

I’m developing a game in C# with the intent of deploying it to the web. Today I opened Unity editor and played a test in the editor. It worked as expected. I then built a test module for the web so that I could let my play-testers have a look. The version I built maintained some functionality, but not all, and made the game unplayable.

I went back to the editor and was surprised to find that it was now also displaying the same glitches. After a minor code update, there are no errors showing in the console, but the problem persists.

Even weirder, I shut the build, closed unity, and upon reopening I had the same experience. The game worked when tested in the Unity Editor, then I decided to try building for PC to see if anything changed, and the exact same glitch happened again. So evidently this isn’t just WebGL related.

Clearly this is some kind of glitch in the build system. What can I do about it?

Also: using 2017.1.1f1 Personal 64 bit

I’ve figured this out so I thought my problem might help someone else.

My game runs a central script (attached to the main camera) which references scripts attached to other objects, including my hero/player. In the main script I have a start function which gets the script component for this hero.

In the unity editor I never had a problem with this, however, after a build the start function in the main script tried to get the script component from the hero despite the fact that the hero had, evidently, not had enough time to calibrate his essential settings. The result was that a sub-functional hero appeared on the screen and did not interact correctly with the main script.

The solution to this problem was to allow the game to take a few frames to update before requesting information from the hero script, at which time the script was properly calibrated and everything started working as expected.

The moral of the story: don’t reference other scripts from your start function or you might get weird results in your build.