Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Unity WebGL calling a function from a jslib file in JavaScript(Vue)

$
0
0
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][1]. 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 page][2]for 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!! [1]: https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html [2]: http://var+UnityJavascipt+=+{+++++//+This+object+can+hold+variables+for+you.+++++$JustAWebGLObject:+++++{++++++++},++++++SendToJavscript:+function+()+++++{+++++++++++console.log("worked!")+++++}++++};+autoAddDeps(UnityJavascipt+,+'$JustAWebGLObject');+mergeInto(LibraryManager.library,+UnityJavascipt+);

Viewing all articles
Browse latest Browse all 1875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>