Displaying a Javascript dialog box in browser from Unity C# causes photon networking to disconnect and crash.
My Unity WebGL game running in a browser needs the user to PAST in some information.
The browser doesnt allow Unity to access the past buffer directly from Unity, so i wrote some JavaScript code to display a PROMPT dialog box so the user can paste in the information. This JavaScript code is called from Unity C# code.
The problem is my game is also using photon networking that constantly needs to ping the server. When my C# code calls the JavaScript code and the dialog box is displayed, the unity engine freeze during the duration of time the JavaScript PROMPT dialog box is being displayed, this freeze prevents photon from pinging the server, so if the user takes more than a few seconds to do the paste and dismiss the dialog box, photon times out and disconnects since it cant ping the server and the game crashes.
Does anybody know why Unity freeze while javascript showns the dialog box? is there anyway around it?
here is my JavaScript code
function DoJavaScriptPaste()
{
var retVal = prompt("Paste Here", "Paste Here");
if (retVal==null) {
retVal="";
}
var buffer = _malloc(lengthBytesUTF8(retVal) + 1);
writeStringToMemory(retVal, buffer);
return buffer;
};
Unity calls the Javascript code like this from C#
[DllImport("__Internal")]
private static extern string DoJavaScriptPaste();
public void DoPaste()
{
string pastedInfo=DoJavaScriptPaste();
text.text = pastedInfo;
}
I even tried calling DoPaste from a C# Coroutine, but Unity Engine still freeze...