I'm trying to call a simple function with callback from [JavaScript plugin][1]. I have the following `jslib` file:
var TestTimeout = {
SetTimeout: function(callback, time) {
setTimeout(callback, time);
}
};
mergeInto(LibraryManager.library, TestTimeout);
The corresponding C# definition is
public class TestTimeout {
public delegate void CallbackDelegate();
[DllImport("__Internal")]
public static extern void SetTimeout(CallbackDelegate callback, int time);
}
That gets called like
void Start() {
CSharp.SetTimeout(Callback, 3000);
}
[MonoPInvokeCallback(typeof(CSharp.CallbackDelegate))]
private static void Callback() {
Debug.Log("Test");
}
But when I do so and build for `WebGL` target and run it from a simple server in Google Chrome 44, I can't recieve log message "Test", and even can't find logging call in code.
How do I properly call a JS function with callback?
[1]: http://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
↧