Browser reload/refresh stay on current scene

You would need distinguish between a navigational click and a browser reload.

A nav click to go to another scene will trigger an onload event.
Reloading the browser will trigger an onload event.

You can distinguish easy enough by having the clicks trigger a function which set a global bool variable.
Thats the easy part. But when your browser reload syou will loose the global vars so you most likely will need to use window.sessionStorage to store the current scene.

All this can be done, and off the top of my head here is an example.

reloadscene.hype.zip (34.1 KB)


A simpler way is to run javascript that sets the page address to the scene name as a anchor '#'

Then all you need to worry about is what scene names to use. The browser will naturally reload the current scene because it is reloading aa anchor.

The Tumult team have posted a simple way of doing this.

The first section on that page Linking to a Scene using an URL is the part you want.
Testing it it works well.

3 Likes