UnityGLTF icon indicating copy to clipboard operation
UnityGLTF copied to clipboard

Loading gltf in WebGL build doesn't work

Open atteneder opened this issue 8 years ago • 2 comments

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)

atteneder avatar Mar 02 '18 17:03 atteneder

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

lilyvelour avatar Mar 07 '18 12:03 lilyvelour

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+c__Iterator1.MoveNext () [0x00039] in <2eb3e637aba84583bf98dc730423517b>:0 at Mono.Linker.Steps.TypeMapStep.TryMatchMethod (Mono.Cecil.TypeReference type, Mono.Cecil.MethodDefinition method) [0x00034] in <2eb3e637aba84583bf98dc730423517b>:0 at Mono.Linker.Steps.TypeMapStep+c__Iterator0.MoveNext () [0x00069] in <2eb3e637aba84583bf98dc730423517b>:0 at Mono.Linker.Steps.TypeMapStep.MapVirtualInterfaceMethod (Mono.Cecil.MethodDefinition method) [0x00022] in <2eb3e637aba84583bf98dc730423517b>:0 at Mono.Linker.Steps.TypeMapStep.MapVirtualMethod (Mono.Cecil.MethodDefinition method) [0x00008] in <2eb3e637aba84583bf98dc730423517b>:0 at Mono.Linker.Steps.TypeMapStep.MapVirtualMethods (Mono.Cecil.TypeDefinition type) [0x0003c] in <2eb3e637aba84583bf98dc730423517b>:0 at Mono.Linker.Steps.TypeMapStep.MapType (Mono.Cecil.TypeDefinition type) [0x00001] in <2eb3e637aba84583bf98dc730423517b>:0 at Mono.Linker.Steps.TypeMapStep.ProcessAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00020] in <2eb3e637aba84583bf98dc730423517b>:0 at Mono.Linker.Steps.BaseStep.Process (Mono.Linker.LinkContext context) [0x00031] in <2eb3e637aba84583bf98dc730423517b>:0 at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00020] in <2eb3e637aba84583bf98dc730423517b>:0 at UnityLinker.UnityDriver.Run () [0x00086] in <1c5a6a9d9114430d85bb9f22788b3702>:0 at UnityLinker.UnityDriver.RunDriverWithoutErrorHandling () [0x00001] in <1c5a6a9d9114430d85bb9f22788b3702>:0 at UnityLinker.UnityDriver.RunDriver () [0x00002] in <1c5a6a9d9114430d85bb9f22788b3702>:0 stderr: ... `

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.

atteneder avatar Mar 16 '18 13:03 atteneder