- Home /
Question by
rasam_hossain · Nov 23, 2016 at 07:34 AM ·
javascriptunity5webgl
WebGL game slows down after triggering javascript event
I am using Unity WebGL to host my game on a flask server and trying to throw a warning to the user whenever he tries to navigate away from the tab or mistakenly click browser's back button. Each time after the event is triggered (whenever I try to navigate away) the game slows down with a huge drop in frame rate (navigation has to be performed after the game has been loaded properly by showing the unity logo and other stuffs). Here is the script that I am using to trigger the event:
<script>
window.addEventListener("beforeunload", function (e)
{
var confirmationMessage = "\o/";
e.returnValue = confirmationMessage;
return confirmationMessage;
});
</script>
What is the work-around of this problem and why the game slows down completely? (I checked with firefox and chrome both !)
Comment