To enable this, we provide you with the ability to include third party JS libraries directly in Luna.
Navigate to the Source Code section the External Sources tab.
Below is an example of an external library we have linked to Luna.
Once the library path has been chosen, to begin using elements from your library you will need to create a new C# script.
Inside your new C# script, one of the first things you will want to do is, make sure you add a
bridge using directive. This is for use during Luna compilation and includes the selected JS library file that it correlates too, within this new C# file.
When using the
bridge namespace, it is important you wrap this directive with a
#if UNITY_LUNA pre-processor as
bridge is not part of Unity and is only used for Luna compilation.
Inside the Luna pre-processor you will also need to add the JS type name, e.g.
[External][Name( "pc.MyTextListener" )]. After C# to JS conversion, this class will be linked to the library's type. Make sure that the JS type is globally visible (or define it with the full name).
Inside this class you should then include every property and method which you need to use in C#, marking them as extern.
Once done you can access those variable methods from C#, such as the following example: