- Home /
Unity WebGL calling a function from a jslib file in JavaScript(Vue)
Hey everyone, I have a VueJs Project right now, where I'm building a web page. In order to show 3D Content and let the User work with it. I wanted to embed a Unity Project as WebGL. I´m not a professional programmer, my knowledge is more selfe-taught from what I can find at the Internet.
First of all I created a plugin, as it is explained here. My .jslib file looks like that:
var UnityJavascipt = {
$JustAWebGLObject:
{
},
SendToJavscript: function ()
{
console.log("worked!")
}
}; autoAddDeps(UnityJavascipt , '$JustAWebGLObject'); mergeInto(LibraryManager.library, UnityJavascipt );
I can also call "SendToJavaScript" from my C# Script. But now it starts to get unclear for me, since I want to be able to call my "SendToJavaScript" Function (or any other one that will be added later) from a outside JavaScript. In the manual they refer to the emscripten pagefor more detailed information. But for me that all is just very confusing. I already tried to call my function like that in VueJs:
_SendToJavaScript()
But I always get a ReferenceError: _SendToJavaScript is not defined I also read in the forum here, that it would be possible to call the function like that:
UnityInstance.Module.asmLibraryArg._SendToJavaScript()
UnityInstance is the Variable from my index.html file, where UnityLoader get's instantiated. But again I'm getting a Reference Error.
It would be very helpful if someone could explain what I'm doing wrong... Communication between WebGL and Vue are essential for my project but I´m stuck here for days. So thanks in advance!!
Your answer
Follow this Question
Related Questions
WebGL build .jspre javascript plugin - how do I call functions from page? 1 Answer
I can't get browser to Webgl communciation working 2 Answers
WebGL: Interacting with browser scripting unable to call java script method from C# 2 Answers
MissingMethodException with jslib calling c# functions 0 Answers