Loading gltf in WebGL build doesn't work
Steps:
- Switch Unity project to WebGL
- Manually spawn local HTTP server with same settings (port 8080, root is UnityGLTF/www; the WebServerComponent didn't work for me in the editor; used a custom python one with proper Access-Control-Allow-Origin header entries).
- Disable/remove the WebServerComponent object from the scene
- Running the scene in the editor works fine now
- Open the BoomBoxTestScene
- Build
- Load result in browser
- Scene shows up, but no GLTF content
- Browser dev tools shows no errors/warnings, Network inspector shows that the gltf file plus all buffers/textures were successfully downloaded
Maybe I'm missing something basic here, but that's hard to tell since I found no detailed instruction on how to get it running on the various build platforms.
Setup Details: on macOS 10.13.3 Unity 2018.1 beta 9 (had to fix minor compiler errors to get it working; nothing fancy though). scripting runtime .NET 4.x equivalent Firefox 59 b12 as well as Chrome Version 64.0.3282.186 (Official Build) (64-bit)
I ran into this as well, and found that the Json.Net DLL in the project wasn't loading in our WebGL project. Compiled one from scratch and all was well. I think that was the only issue I needed to fix (I didn't try to reproduce it again so there could be something else here).
Thanks for the tip! I retried with a fresh checkout and Unity 2017.3.1f1 today with an updated master (I noticed Unity 2017.2/3 compatibility was added in the meantime).
Out of the box the WebGL build fails with the following error:
`Failed running /Applications/Unity/Hub/Editor/2017.3.1f1/Unity.app/Contents/il2cpp/build/UnityLinker.exe --api=NET_2_0_Subset -out="/Users/Shared/SDK/UnityGLTF/UnityGLTF/Temp/StagingArea/Data/Managed/tempStrip" -l=none -c=link --link-symbols -x="/Applications/Unity/Hub/Editor/2017.3.1f1/PlaybackEngines/WebGLSupport/Whitelists/Core.xml" -f="/Applications/Unity/Hub/Editor/2017.3.1f1/Unity.app/Contents/il2cpp/LinkerDescriptors" -x "/Users/Shared/SDK/UnityGLTF/UnityGLTF/Temp/StagingArea/Data/methods_pointedto_by_uievents.xml" -x "/Users/Shared/SDK/UnityGLTF/UnityGLTF/Temp/StagingArea/Data/UnityEngine.xml" -x "/Users/Shared/SDK/UnityGLTF/UnityGLTF/Temp/StagingArea/Data/preserved_derived_types.xml" -d "/Users/Shared/SDK/UnityGLTF/UnityGLTF/Temp/StagingArea/Data/Managed" -a "/Users/Shared/SDK/UnityGLTF/UnityGLTF/Temp/StagingArea/Data/Managed/Assembly-CSharp.dll"
stdout:
Fatal error in Unity CIL Linker
System.NullReferenceException: Object reference not set to an instance of an object
at Mono.Linker.TypeReferenceExtensions+
Then switched the Unity Project's "Scripting Runtime Version" to ".NET 4.6 equivalent", re-built the GLTFSerialization project with the target framework changed to ".NET Framework 4.5" and (thanks for your help) replaced the JSON dll and xml with the correct version ( GLTFSerialization/packages/Newtonsoft.Json.9.0.1/lib/net45/Newtonsoft.Json.dll +xml ).
Initially this didn't work, but now it showed an error in the console stating that the shader was missing (maybe that's the only problem I had).
So after preloading a shader variant collection that included the necessary GLTF/PbrMetallicRoughness variants, it worked.
Still, some docs would be great.
hth and thanks again.