Does anyone know how to do this? I can send data to the jslib plugin just fine, but I don’t know how to get that plugin code to talk to a containing page’s javascript. For example, I have:
var outsideHandler = function(name, score){
console.log("got name and score from outside unity: " + name + "," + score);
}
var unityInstance = UnityLoader.instantiate("unityContainer", "Build/racingbuild.json", {onProgress: UnityProgress});
but the jslib functions do not recognize my “outsideHandler” function.
It was so much easier to do this with ExternalCall, which I know is deprecated, which means there must be something I’m overlooking. I hope?
I’ve also tried this, to no avail:
unityInstance.Module.outsideHandler = function(){
function receiveNameAndScore(name, score){
console.log("got name and score from outside unity: " + name + "," + score);
}
return {receiveNameAndScore: receiveNameAndScore}
}();
var outsideHandler = function(name, score){
console.log("got name and score from outside unity: " + name + "," + score);
}
var unityInstance = UnityLoader.instantiate("unityContainer", "Build/racingbuild.json", {onProgress: UnityProgress});
In this code example, I think you can execute it with outsidehandler(); inside a function in jslib.
Thanks. What I had to end up doing is calling “document.outsideHandler()” from the jslib function, and setting document.outsideHandler to the method I had above, in the container.
Now, if I could figure out how to do this across an iframe…
(this all isn’t my decision, it’s what a client wants)