Search Unity

How to close the WebGl game or clearing the content while navigating to another page.

Discussion in 'Web' started by rameshkumar, Sep 29, 2015.

  1. rameshkumar

    rameshkumar

    Joined:
    Aug 5, 2013
    Posts:
    50
    for mobile platforms or pc we can use Application.Quit() but for WebGL , how to close it ..any idea or alternative solutions.
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    In the title you wrote "while navigating to another page". That part I don't understand. If you navigate to another page (either due to the user explicitly doing so, or from your JS code), the WebGL content will automatically be closed? So why/how do you want to close it?
     
  3. danielschaffer

    danielschaffer

    Joined:
    Jun 12, 2015
    Posts:
    1
    I've got a single-page web app that hosts the game. If the user navigates away from the game, I need to be able to shut it down. I haven't been able to figure out a clean way of doing that. I've tried calling Module.exit(), Module.abort(), but the game still keeps trying to access the canvas even after everything is removed.
     
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    There is currently no simple way to my knowledge to completely unload an emscripten exectuable and all it's code. My recommendation would be using an iframe.