#Importing JavaScript Libraries into Unity as a plugin
1 messages · Page 1 of 1 (latest)
The process of creating a .jspre file should be just renaming the JS library file to have that extension
.jslib is then used as an interface to the library as per the manual
So then just change the extension for the existing library, and create a .jslib that calls the functions in the library?
How would you link the two, just have an import statement at the top of the .jslib?
You can't use modules in plugins. They're limited to ES5
If you need ES6 you can include the libraries in the HTML template normally with <script> tags
So, if I have a function Foo in the existing library, how do I call it from the .jslib interface? Is it automatically added to the DOM (if that is the right term I am still new to web stuff)?
The instructions are here: https://docs.unity3d.com/Manual/web-interacting-browser-js.html
mergeInto(LibraryManager.library, { Foo });
(Automatically added to the global scope, not DOM, but I get what you meant)
Yeah, it was vague enough for me that I couldn't quite piece together how the two file types could intermingle.
Got it, so just rename the file extension on the existing library, and then create an interface in the .jslib file calling the functions I want to use in the existing library.
That about cover it?
That should be it