Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unitypackage] Improve WebGL export #759

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

timbotimbo
Copy link
Collaborator

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 pause and resume functions.

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)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@jesseburstrom
Copy link

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.

@timbotimbo
Copy link
Collaborator Author

timbotimbo commented Feb 7, 2023

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.

@jesseburstrom
Copy link

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!

@timbotimbo timbotimbo changed the title Improve WebGL export [Unitypackage] Improve WebGL export Nov 5, 2023
@Ahmadre
Copy link
Collaborator

Ahmadre commented Jan 2, 2024

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).

@Ahmadre
Copy link
Collaborator

Ahmadre commented Jan 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Unity 2019] 3d Model gets cropped out when resized in web
3 participants