WebGL Build uses old script, can't update to a newer version!
Hi everyone,
As the title says, I'm trying to export my project to WebGL, but the scripts the build loads are an outdated version. The project runs fine on the editor, but whenever I build and run my project, it loads the previous script instead of the updated version. In the Inspector, the script is fine - so that rules out a few solutions that I also tried just in case.
I searched online for several hours, tried everything to fix this and I can't figure out what's causing it or how to fix it. Any ideas?
Things I've tried:
-Restarting unity, computer, moving to a new house (kidding... well, not really...) -Cleaning the browser's cache, cookies, app content etc. -Setting Edit->Preferences->General->Auto Refresh to ON -Directory Scanning -Resetting the GameObject that holds the script -Removing the script's meta file to let it regenerate (the meta file was old) -Creating a copy of the project and running it from the copied version -Disabling anti-virus, setting files and folders to admin+write access -Deleting the build and temp folders from the project -Tried different browsers... -Removed/added the scene to the build menu
Here's how I know it's loading the old script. -I copied most of the code from another section of the project that used fonts. However, once I noticed the Debug.Log was mistakenly mentioning "Selected Font" instead of "Selected Background Option", I corrected it. There are also other visual issues with the build version related to the old script.
Please refer to the images I'm uploading: on the larger image, the left part is the Javascript debugger on the browser, the right section is Unity's editor inspector.
Again, this runs well at runtime in the editor (play button), but it loads the old script when built. The smaller image refers to Unity's runtime console output:
The windows standalone export seems to run correctly, although I'm not able to access the console to be 100% sure. This only seems to affect the WebGL build.
I'm lost. Please help! :( Thank you! -ViLa
Answer by God0fMagic · Nov 17, 2021 at 09:12 AM
I have the same issue. It was updating fine for a while and then suddenly stopped updating. I checked that it is the wrong version by simply having a debug on start that I changed between builds. On editor works fine, in the build it debugs the old message.
It first started happening with Asset Bundles. Webgl build has a link to asset bundles in the server. I updated them, but in the build still the old version was being loaded. I even deleted asset bundles from the server so that link inside the build points at an empty directory - and it still loaded old asset bundles.
What helped was changing the directory where asset bundles are hosted and rebuilding the game.
A few builds later game stopped updating as well as asset bundles and now the only option is to change the directory of both game and asset bundles each time I want to update something.
Would be great to know if there are any solutions to this problem. Using Unity 2021.1.17f1
Hi @God0fMagic, unfortunately, I had a bunch of issues going on at the time I made this post, so I can't remember what ultimately fixed it, but one thing that messed up my builds pretty bad was updating visual studio to the latest version. I've downgraded to VS Community 2017 (v15.9.39), and things seem to be running much more smoothly. From what I understood there was some sort of bug with running scripts in WebGL builds. Since a couple of weeks ago, I keep getting a warning asking to update VS, but I'm not touching it until it breaks again.