- Home /
Question by
cesartalves · Jun 17, 2018 at 04:17 PM ·
networkingwebgljs-c#
Call Unity function from inside .jslib javascript function in Webgl
Is it possible to call a function in Unity from within the .jslib file? Something like this:
var loadFromUrlPlugin = {
loadDataFromUrl: function(link){
var url = Pointer_stringifyl(link);
fetch(url).then(function(response){
response.text().then(function(text){
//Will this work?
gameContainer.SendMessage('JsListener', 'SetBodyFromText', text);
})
});
}
}
mergeInto(LibraryManager.library, loadFromUrlPlugin);
Comment
Best Answer
Answer by cesartalves · Oct 15, 2018 at 04:25 PM
By doing a console.log(SendMessage) from within the .jslib, I could see it was defined. Therefore, though I haven't checked the precise example from my question, something like it should work. Just remove the 'gameContainer' part and call SendMessage directly.
Your answer
Follow this Question
Related Questions
WEBGL Loading bar not showing on Microsoft Edge Unity 2020.1 0 Answers
Network information 1 Answer
How to close websocket connection on server? 1 Answer
Local host in WebGL 1 Answer
WebSocket and WebGL error 1 Answer