Is it possible to disable hot-swapping?

I am working with playcanvas deployed in an Angular application and I am having some troubles.

I have an angular component which renders my Playcanvas app. It works perfectly, but when I change to another component (without playcanvas content) and come back to the first one I get the following error:

scripts.bundle.js:929 script registry already has ‘keyboardInput’ script, define ‘swap’ method for new script type to enable code hot swapping

This happens for every script I have in my Scene.
If I reload the page, it works as supposed.

  • Is there any way I can force my scripts to fully reload instead of trying to Swap??
  • Can I disable Hot-Swapping in my project or Scene?


In your error code example, did you change the keyboardInput script at any point?

Hi Yaustar, thanks for responding.

This problem happens with all the scripts I have in my scene, not only with keyboardInput.

It sounds like the workflow that is being used is removing and readding the PlayCanvas scripts. As the PlayCanvas app object is global, it retains the pc.Script objects unless it is destroyed.

So… is there a way I can destroy all pc.Script Objects of the engine and force them all to reload?

You are probably best off finding a way to reload the PlayCanvas rendering angular component.

Or put the PlayCanvas app in an iframe to isolate it?

Edit: Are the warnings an issue beyond the spamming of the console?

I’m gonna try to force reloading of the component…

Beyond the spaming of the console, my scene is not fully loaded as any of the scripts can be loaded.