Skip to content

Commit 8d58707

Browse files
committed
add confirm dialog
By default, this feature will be disabled
1 parent 9ed9203 commit 8d58707

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

unity/Assets/WebGLTemplates/Modern/index.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@
8686
}
8787
}
8888
}
89+
90+
function confirmUnload(event) {
91+
return confirm("All unsaved progress will be lost.");
92+
}
8993

9094
var buildUrl = "Build";
9195
var loaderUrl = buildUrl + "/{{{ LOADER_FILENAME }}}";
@@ -142,6 +146,10 @@
142146
progressBarFull.style.width = 100 * progress + "%";
143147
}).then((unityInstance) => {
144148
loadingBar.style.display = "none";
149+
150+
// If you want to warn the player before they close the tab,
151+
// uncomment the following:
152+
//window.onbeforeunload = confirmUnload;
145153
}).catch((message) => {
146154
alert(message);
147155
});
@@ -151,4 +159,4 @@
151159
document.onfullscreenchange = rebuildFullscreenGUI;
152160
</script>
153161
</body>
154-
</html>
162+
</html>

0 commit comments

Comments
 (0)