0

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?

gman
  • 100,619
  • 31
  • 269
  • 393
SaberTooth
  • 157
  • 1
  • 4
  • 15
  • does this happen in all browsers – Jaromanda X Nov 23 '16 at 05:47
  • I checked with firefox and chrome. Both are behaving same. I needed something that will work at least both chrome and firefox so was not bothering other browsers. I will now check the others to confirm this. – SaberTooth Nov 23 '16 at 05:52
  • the fact that it behaves the same in two browsers means it's not likely to be a browser bug, no need to test those rubbish browsers :p – Jaromanda X Nov 23 '16 at 05:53
  • That means no need to test others. No idea yet what's causing the error and slowing everything down. – SaberTooth Nov 23 '16 at 05:55

0 Answers0