How can I run Unity3D WebGL player with absolute paths to assets?
We're working on a furniture 3D-model player made with Unity3D. After NPAPI support had been discontinued by Chrome and Unity3D Plugin had stopped working, we've started to move the player to the WebGL technology. Both player and furniture viewer work fine thoriugh Unity Editor.
But for furniture player library it's required to use absolute paths to files came from Unity build (example, before - WebPlayer.unity3d, after - WebGLPlayer.js, WebGLPlayer.data, WebGLPlayer.html.mem, etc.). After I've got all the files loaded, this error begun to appear. It's stack trace goes deep to the asm.js, which is unaccessable to read and debug.
Error description:
exception thrown: TypeError: Cannot read property 'addEventListener' of undefined,TypeError: Cannot read property 'addEventListener' of undefined
at Object.JSEvents.registerOrRemoveHandler (http://host/player/WebGL/Release/WebGLPlayer.path_fixed.js:1:115907)
at Object.JSEvents.registerMouseEventCallback (http://host/player/WebGL/Release/WebGLPlayer.path_fixed.js:1:119681)
at _emscripten_set_mousedown_callback (http://host/player/WebGL/Release/WebGLPlayer.path_fixed.js:1:191086)
at BCc (http://host/player/WebGL/Release/WebGLPlayer.path_fixed.js:18:614839)
at Object.eCc [as _main] (http://host/player/WebGL/Release/WebGLPlayer.path_fixed.js:18:609112)
at Object.callMain (http://host/player/WebGL/Release/WebGLPlayer.path_fixed.js:31:49538)
at doRun (http://host/player/WebGL/Release/WebGLPlayer.path_fixed.js:31:50368)
at run (http://host/player/WebGL/Release/WebGLPlayer.path_fixed.js:31:50536)
at runCaller (http://host/player/WebGL/Release/WebGLPlayer.path_fixed.js:31:48822)
at Object.removeRunDependency (http://host/player/WebGL/Release/WebGLPlayer.path_fixed.js:1:28378)
WebGLPlayer.path_fixed.js is a WebGLPlayer.js copy with paths to WebGLPlayer.data and WebGLPlayer.html.mem files fixed.
Is there any way to fix this? Is it possible to make custom WebGLPlayer.js build to avoid this errors?
Answer by atnartur · May 02, 2016 at 07:42 PM
At this time problem was fixed by using iframe HTML tag. We simply initialize iframe page with WebGL instance of player. Unity3D probably have not a way to customize paths to resources.
Answer by TylerO · May 01, 2016 at 09:16 AM
Any solution to this yet? I am having the same issue! I can't seem to figure it out.