I'm working on a prototype that involves a little bit of tinkering with Unity's generated javascript code. Specifically, I can make a development build, make some tweaks to the [build].wasm.framework.unityweb file, and then my feature works (specifically, I made some changes so that I can use the camera on iOS safari, which is not currently supported). I want to do something similar to what's described in this thread, but I want it to work in non-development builds as well: https://forum.unity.com/threads/device-camera-in-webgl.523253/#post-3436044 So let's say I want to make a change to "_JS_WebCamVideo_Start". I had GUESSED that I'd be able to modify, within my Unity installation, Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/lib/UnityNativeJs/UnityNative.js. But that didn't do anything (I deleted the file and I could still build fine, even after deleting temp files. That confuses me, I'm not sure why this file is there then...) My hope was that I could modify that file, and then, when I'm doing a non-development build, cross my fingers that Unity would gzip my changes to that file automatically. Wishful thinking perhaps! Any tips on an efficient way to do this? Edit: On 2018.3.4 at the moment
Some progress here. First, what didn't work. I tried taking the framework.unityweb file (attempted with both gzip and brotli), decompressing it (that worked), then recompressing it. Just to see if I could make my own compressed file. I couldn't quite get that working, perhaps there are specific compression settings or details in the header. So I ruled out being able to make my own compressed framework.unityweb file. However, I did realize that I can mix-and-match. So, I could have an uncompressed framework.unityweb file, but I can still have gzip/brotli compression for the other unityweb files (which are bigger anyways). So, my process looks like: -Build the game with no compression -Build the game with my compression of choice -Modify the uncompressed framework.unityweb file -Replace the framework.unityweb file in the compressed build with my modified (uncompressed) one -Voila, I can use that compressed build. I'll write some scripts to automate this build process now. However, if there is a way to change Unity's javascript templates outright instead of this roundabout approach, I'm all ears!
Do you have tryed to delete your Project directory/Library/webgl_cache and Project directory/Library/il2cpp_cache after the files modification ? I have already modified few js file because of bug's with mouse and audio and it worked for me.
Hmm, I had deleted my whole Library folder. Though the fact that it worked for you has me wondering if I somehow botched that test? I'll try again.
Yup no dice for me. My steps: Close my Unity project Open and modify: <Unity installation>\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\lib\UnityNativeJs\UnityNative.js Delete Library/webgl_cache and Library/il2cpp_cache (I had previously done this test deleting all of Library as well) Make a build of the game (with 'Disabled' compression for easy inspection) Inspect the output Build.wasm.framework.unityweb file And, for me, that file did NOT have any of the modifications I made. Did this work for you @roka ? Or did you do any steps slightly differently?
Ok worked it out! The particular file I was modifying was not the right one. There are a few javascript files in this directory with duplicated code, and I'm not sure what the one I was editing did (even deleting it didn't change anything) (I put it back later just in case ). However, I was able to modify other files and those changed did stick when I built. Files like... Unity Install/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/lib/WebCam.js Unity Install/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/prejs/MediaDevices.js Thanks for your help, encouraged me to stick with it! I got thrown off scent by the duplicated code.