[Unitypackage] Improve WebGL export
Description
For WebGL exports, the function ModifyWebGLExport adds some extra functionality to Unity's index.html using string.replace.
Even If this replacing fails, the build will succeed and the user gets bugs or unintended behaviour in the browser.
For example WebGL doesn't work properly when exported using Unity 2019.
This pull request:
- Makes the search and replace more robust to player setting changes
- Improves compatibility with the Unity 2019 index.html
- Log errors for the user when the replace did not succeed
- Fixes an unrelated bug that broke the
pauseandresumefunctions.
This probably won't fix every single Unity version, but users will now get an error message that might help in finding the problem.
Tested this to work with Unity: 2022.2.5, 2021.3.14, 2020.3.42, 2019.4.40, 2019.4.23
Based on #754 I assume that 2022.1.0b5 doesn't work yet, but that is an (outdated) beta release. This also fixes #755.
Type of Change
- [ ] โจ New feature (non-breaking change which adds functionality)
- [x] ๐ ๏ธ Bug fix (non-breaking change which fixes an issue)
- [ ] โ Breaking change (fix or feature that would cause existing functionality to change)
- [ ] ๐งน Code refactor
- [x] โ Build configuration change
- [ ] ๐ Documentation
- [ ] ๐๏ธ Chore
Ok, I think it is easier to lock the .html file since it really is never changing from version to version in a functional way. Also I still want to have transparency and dynamical sizing without scrollbars. So I do not have to override the html file after each export. Hmmm I modify build.cs myself.
I agree that anyone seriously using this would probably need to customize their export.
This simply tries to make the current behavior more consistent over different Unity versions.
Working with fixed html templates is a good idea for a future change. But that might fail completely when Unity does make a breaking change.
I agree and have suggestion. Why not provide index.html next to build.cs and have versions on your repo for user to download with instructions where to put. That way breaking change is easily fixed by supplying new index.html. Great work by the way really nice flutter widget!
I agree and have suggestion. Why not provide index.html next to build.cs and have versions on your repo for user to download with instructions where to put. That way breaking change is easily fixed by supplying new index.html. Great work by the way really nice flutter widget!
The reason is because Unity is generating that file (depending on which Unity version you got).
Ok, I think it is easier to lock the .html file since it really is never changing from version to version in a functional way. Also I still want to have transparency and dynamical sizing without scrollbars. So I do not have to override the html file after each export. Hmmm I modify build.cs myself.
I agree. We maybe need some way to customize that. I also do change the exported files, but I have a script for that.