Close tab from webGL build
Hey, is it possible to close the tab with the game from within the webGL build? I mean the same way I would close an apllication with Application.Quit. Thank you
Answer by BreckCooper · May 12, 2020 at 06:25 PM
Doubt you still need this, but here is the answer for future people looking.
Create a .jslib file and place it inside Assets -> Plugins folder. In this file you can add your javascript like so.
mergeInto(LibraryManager.library, {
closewindow: function (){
window.close();
}
}
Now call this from a Unity file like this.
using UnityEngine;
using System.Runtime.InteropServices;
public class QuitApp : MonoBehaviour
{
[DllImport("__Internal")]
private static extern void closewindow();
public void QuitAndClose()
{
Application.Quit();
closewindow();
}
}
This don't work for me. It says that closewindow function is missing. Any idea how to fix?
@Toscan0 this works for me:
var CloseWindowPlugin = {
closeWindow: function ()
{
window.close();
}
};
mergeInto(Library$$anonymous$$anager.library, CloseWindowPlugin);
Your answer
Follow this Question
Related Questions
Browser and Server Communication Problem - Server only receive One text? 0 Answers
What's the proper way to make my game listen to a browser's javascript event? 0 Answers
WebGL & denying browser script access to game methods? 0 Answers
webgl app is not working in browser 0 Answers
open PDF on WebGL 0 Answers