I have some issues regarding Unity WebGL and browser communication.
Is it possible to make JavaScript function for events onUnityFinishedLoading or onStartsPlaying?
On the opposite side when calling JavaScript from Unity functions returning strings return null. However functions returning int work fine.
This is a sample code for this:
var MyPlugin = {
Hello: function()
{
window.alert("Hello, world!");
return "5";
},
HelloStr: function()
{
window.alert("Hello, world! str");
return "str 5";
}
};
mergeInto(LibraryManager.library, MyPlugin);
using System.Runtime.InteropServices;
public class ExternalEval : MonoBehaviour
{
[DllImport("__Internal")]
private static extern int Hello();
[DllImport("__Internal")]
private static extern string HelloStr();
// Use this for initialization
void Start()
{
Debug.Log(Hello());
Debug.Log(HelloStr());
}
}
How do I resolve this issues?