(For the WebGL target: ) The page here ( https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html ) shows how to create JavaScript functions callable from Unity3D C# scripts.
But how do I call a common JS function from those exported functions? The two obvious attempts both failed to work:
mergeInto(LibraryManager.library, {
Foo: function() {
common(1);
},
Bar: function() {
common(2);
},
common: function(val) {
},
});
Unsurprisingly doesn’t work, because “common” isn’t a known function name, but rather just another name in the anonymous object being defined. But then, the following dsoesn’t work either:
function common(val) {
};
mergeInto(LibraryManager.library, {
Foo: function() {
common(1);
},
Bar: function() {
common(2);
},
);
That fails at runtime, claiming “common” isn’t defined.
So just how do I call another JS function from a Unity3D-imported JS function?