I have a project I intend to have two clients ; a VR client and a WebGL client. I am using the Oculus Integration package as well to build to Oculus Quest.
While everything runs correctly in Android, when I try to build the project in WebGL, I have an error concerning the Microphone class.
When stubbing it, build work but the WebGL player cause the following error :
“To use dlopen, you need to use Emscripten’s linking support”
This error looks to be caused by Oculus Integration, because when removed, the player works successfuly.
Is there a way to make WebGL and Oculus Integration work in the same project ? There is very few things different between clients, so I’d rather not having separate projects, because sharing code is such a chore in Unity.
I eventually worked around by making actually two separated projects ; a WebGL and a Oculus. My assets got on both projects using a folder with logical links, and only the Oculus project had the Oculus integration & Unity XR packages.
For the few of my scripts depending on XR, I used #if UNITY_WEBGL to comment them out.
Anybody has tested this process with Assembly definition? Didn’t find the right config… The solution with logical link does seem acceptable but this would be much cleaner with assembly.
Have you tried WebGL build in the same VR/Oculus project? I am working on a multiplayer project which has Oculus Integration and PUN as resources. The project needs to be on two platforms: Oculus and WebGL. When I am going to build WebGL, the build is successful(after some changes script code commented execution for WebGL).
But when i am trying to run it gives an error : ("To use dlopen, you need to use Emscripten’s linking
Adding an Assembly reference is a great Idea and a lot better than removing the whole package at every WebGl build or having two projects I think.
So in general: With Assembly references you can control if the code will exist in certain plattforms. You can exclude all the code that is in the same folder as the Assembly Reference Asset File and all subfolders (that don’t have an Assembly Reference File themselves) by ticking the checkboxes of your Assembly file. This is exactly what we need here (exclude Oculus files when we build for WebGL)
In 2022 it seems this process has changed a bit. I had to do the following:
First of all we want to find all the Assembly Definition files of our Oculus Plugin and tick the “WebGL” checkbox in the “Exclude Platforms” list.
Oculus added a couple of Assembly Definition files in their latest version and those files are all hidden in the subfolders of the “Assets\Oculus” folder. For example this one is in the folder "Assets\Oculus\AudioManager:
In order to find all of those Assembly files, I was using a simple windows search for “*.asmdef” in the Asset\Oculus folder.
So let’s open the Oculus folder by opening it like so: (2021.3.2f1).
Enter “*.asmdef” into your windows file search bar to find all Assembly Definitions that are now included in the current Oculus Plugin and therefore exist in the “Oculus” Folder just like this:
Keep in mind to ONLY Exclude those Assembly Definitions from WebGL, that are NOT Editor Assemblies(if the word Editor is in them, then don’t edit them).
Last but not least, create an Assembly Definition File directly in your Oculus Folder, call it
“Oculus.All” and include ONLY the Editor. As in the main level there will only be Editor Scripts. Then add those three necessary Assemblies to that Assemblydefinition that will be needed:
Unity.TextMeshPro
Oculus.VR and
Oculus.Platform.
It should look like so: (in the image I have some more assemblies added but they are not needed, I just forgot to put them out again):
Now your webgl build should work like a charm. cheers.
remember to like this post if you liked it. thank you
I am working on a project where I plan to build two clients : a VR client as well as an WebGL client. I use the Oculus Integration program to create Oculus Quest.
Although everything works fine in Android however, when I attempt to build the application in WebGL I get an error with microphone.
If you stub it, build works, but the WebGL player will give the following error “To use dlopen, you need to use Emscripten’s linking support”
The error appears to be due to Oculus Integration, because when removed, the player functions successfully.omegletv.
Is there a way to have WebGL as well as Oculus Integration work together in the same project? There are very few aspects that are different between the two clients, and I’d prefer not to have separate projects because sharing code can be a hassle in Unity.
Hi omegletvcam…
I am currently working on a project that has to be built for both Oculus and WebGL. You have to do some tweaks in order to get it to work for both platforms.
The Oculus SDK uses that Microphone which causes WebGL to not work. In the very post above your post, I have described in a detailed way, how you can track down and exclude the Oculus SDK’s Assembly Definitions, so that they get excluded from your WebGL Build. Do that and the WebGL Microphone Errors will disappear.
There is more to be done however.
On some occasions you will have to exclude code from being built for the one or the other plattform with compilerdirectives like this: #if !UNITY_WEBGL #endif
like this:
Also In order to upload your APK Android Build to the Oculus Store you will have to remove the Microphone permit with your own custom Manifest. Otherwise you will not be allowed to publish your APK to the Oculus Store - uploading for the Alpha/ Beta Channel will work, but not publishing it to the open world.
Here is my version of the AndroidManifest. As soon as you tick the “Custom Main Manifest” checkbox, it will create some AndroidManifest in the given folder (Assets\Plugins\Android\AndroidManifest.xml) and you can edit it with the following:
There is a simple way to fix some issues like this when you know the exact piece of code that is causing errors. You first need to find the non cashed script and there you can rewrite the code and then refresh the cashed version of the script. For me I wanted to build WebGL but I was getting error while building pointing to script called VoiceLipSyncMic.cs to line 49. So I found the non cashed script in the AppData Unity folder (Not in project folder):
Then you can write something in the cashed script just so Unity knows it has to recompile it and when you open Unity the cashed script is refreshed from the non cashed script and you are good to go.