I’m building a project to both VR and WebGL.
Obviously I don’t want the Oculus SDK in my WebGL build, lucikly -i thought- the XR plugin management fixes this.
But the Oculus SDK is included in any target despite those settings. So what does the XR plugin management really do? And why is it so hard to create cross platform solutions with Unity. You would expect to be able to just exclude certain things from certain targets in an easy way???
Cloud build errors for WebGL:
[Unity] -----CompilerOutput:-stdout–exitcode: 1–compilationhadfailure: True–outfile: Temp/Assembly-CSharp.dll
[Unity] Assets/Oculus/Avatar/Scripts/OvrAvatar.cs(985,28): error CS0103: The name ‘Microphone’ does not exist in the current context
[Unity] Assets/Oculus/Avatar/Scripts/OvrAvatar.cs(1008,9): error CS0103: The name ‘Microphone’ does not exist in the current context
[Unity] Assets/Oculus/Avatar/Scripts/OvrAvatar.cs(1015,26): error CS0103: The name ‘Microphone’ does not exist in the current context
[Unity] Assets/Oculus/Avatar/Scripts/OvrAvatar.cs(1021,9): error CS0103: The name ‘Microphone’ does not exist in the current context
[Unity] Assets/Oculus/LipSync/Scripts/OVRLipSyncMicInput.cs(117,13): error CS0103: The name ‘Microphone’ does not exist in the current context
[Unity] Assets/Oculus/LipSync/Scripts/OVRLipSyncMicInput.cs(121,26): error CS0103: The name ‘Microphone’ does not exist in the current context
[Unity] Assets/Oculus/LipSync/Scripts/OVRLipSyncMicInput.cs(135,17): error CS0103: The name ‘Microphone’ does not exist in the current context
[Unity] Assets/Oculus/LipSync/Scripts/OVRLipSyncMicInput.cs(161,22): error CS0103: The name ‘Microphone’ does not exist in the current context
Truncated to 10 lines.
Yeah XR Management doesn’t do much.
The Oculus scripts are included to any platform so the key was to handle this manually. I ended up creating assemblies for the whole oculus SDK, and excluding them from WebGL. It is quite some linking and clicking, but in 15 mins you should be good to go.
In short: in the root folder of the oculus SDK, you click right mouse and create an assembly file. However, you have to make exceptions (e.g. create assembly files) for each Editor folder down the hierarchy, and then link those assemblies back to the main assemblies to solve reference errors.
Again. what do you mean with the oculus SDK?
If you mean the Oculus Integration package (https://assetstore.unity.com/packages/tools/integration/oculus-integration-82022), this is not a part of Unity/XR Management and thus will not be changed per build platform.
If this happens from the Unity Oculus package (just called Oculus and installed by clicking the checkmark in XR management), this should not happen and you should open a bug report
Did you ever solve this? I also want to produce a webgl build as an alternative to my VR build but the Oculus SDK does not use ifdefs to mask out the usage of the Microphone API which then produces compile errors.
I did solve it, I described it above. So the first step is to go into the Oculus Plugin folder in Assets. Create right: Create: Assembly Definition. There you can select for what platforms that assembly will be included or excluded. So exclude for WebGL. But there will be compilation errors, so you have to make new assemblies in certain sub folders with exclusion…