0

I'm loading in a component the unityloader javascript and instantiate in the mounted section of my component. Everything works fine until I click on a router-link or nuxt-link. The DOM is probably modified at that moment and the game instance is losing the control on the DOM and start looping.

I would like to destroy the unityloader but there's no clear documentation on this generated code. Any idea on how I could do this?

keep-alive maybe?

this.gameInstance = UnityLoader.instantiate('unity-container', this.src, params);

gman
  • 100,619
  • 31
  • 269
  • 393
Bliard
  • 45
  • 5

1 Answers1

0

I've finally found a solution to this issue.

Reflective bug: Unity WebGL continues to run after content is removed

I've added the bellow to the unity.vue to the package.

beforeDestroy() {
        if(this.gameInstance && this.gameInstance.Quit){
            this.gameInstance.Quit();
        }
    },

In the mean time, if you want a now solution, and don't want to upgrade to an unstable version. You can pull out the Unity.vue file from the package, and edit it to be wrapped in an Iframe and dispose of the iframe when un-mounting.