I’m exploring some functionalities within WebGL to see how to get things done that way. But I’m having trouble getting a javascript plugin working within a build.
I used this documentation to get started:
The build I made running at:
https://jdmulti.nl/research/jdmulti_modelviewer/
Build with: Unity 2018.2.0f2
Running in: Chrome 67.0.3396.99
Operation System: Windows 7
I’ve created an javascript plugin in: Assets/Plugins/WebGL/ImageUploader.jslib with this code:
Assets/Plugins/WebGL/ImageUploader.jslib
mergeInto(LibraryManager.library,
{
Hello: function ()
{
window.alert("Hello, world!");
},
});
Then I created an C# script doing this:
using UnityEngine;
using System.Runtime.InteropServices;
public class ImageUploader : MonoBehaviour
{
[DllImport("__Internal")]
private static extern void Hello();
public void OnButtonUpload()
{
Hello();
}
}
In the view I’ve got a button which will execute the function: ‘OnButtonUpload’ when pressed. But when I test it locally or on my server I won’t get it successfully run and instead get the error:
UnityLoader.js:4 missing function: Hello
printErr @ UnityLoader.js:4
Invoking error handler due to
Uncaught abort(-1) at Error
at jsStackTrace (WebGL.wasm.framework.unityweb:2:22127)
at stackTrace [Object.stackTrace] (WebGL.wasm.framework.unityweb:2:22298)
at Object.onAbort (https://jdmulti.nl/research/jdmulti_modelviewer/Build/UnityLoader.js:4:10650)
at abort (WebGL.wasm.framework.unityweb:2:481498)
at _Hello (WebGL.wasm.framework.unityweb:2:46544)
at wasm-function[23228]:1
at wasm-function[14281]:273
at wasm-function[14474]:22
at wasm-function[14500]:104
at wasm-function[12688]:77
at wasm-function[12689]:15
at wasm-function[12458]:152
at wasm-function[12462]:100
at wasm-function[22190]:114
at wasm-function[29565]:20
at dynCall_viiii [Object.UnityLoader.522d0a97dcf11b9129d21cebf76de72a.Module.dynCall_viiii] (WebGL.wasm.framework.unityweb:2:473723)
at invoke_viiii (WebGL.wasm.framework.unityweb:2:373474)
at wasm-function[27267]:341
at wasm-function[12386]:11
at wasm-function[12633]:1231
at wasm-function[12632]:251
at wasm-function[12631]:7
at wasm-function[12626]:106
at wasm-function[12390]:46
at wasm-function[12429]:523
at wasm-function[27958]:16
at wasm-function[29539]:20
at dynCall_iiiii [Object.UnityLoader.522d0a97dcf11b9129d21cebf76de72a.Module.dynCall_iiiii] (WebGL.wasm.framework.unityweb:2:462887)
at invoke_iiiii (WebGL.wasm.framework.unityweb:2:356649)
at wasm-function[24148]:170
at wasm-function[24286]:36
at wasm-function[2102]:67
at wasm-function[2101]:109
at wasm-function[6510]:473
at wasm-function[6498]:5
at wasm-function[8865]:721
at wasm-function[8864]:3
at wasm-function[7252]:30
at wasm-function[6600]:147
at wasm-function[6600]:170
at wasm-function[6595]:525
at wasm-function[6589]:200
at wasm-function[24759]:12
at dynCall_v [Object.UnityLoader.522d0a97dcf11b9129d21cebf76de72a.Module.dynCall_v] (WebGL.wasm.framework.unityweb:2:468842)
at browserIterationFunc (WebGL.wasm.framework.unityweb:2:133798)
at runIter [Object.runIter] (WebGL.wasm.framework.unityweb:2:136871)
at Browser_mainLoop_runner (WebGL.wasm.framework.unityweb:2:135333)
I’ve been trying several things which included removing the path within the javascript plugin and the path within Unity is also correct. Is there a place where I need to drag the plugin file into to have it included in my build? I’m clueless at the moment.
Another question, is there a way to debug javascript plugins within the editor as build times take some time before you can test it, someone has a good workflow for that?