Reloading script assets


I am using a Playcanvas project inside an Angular application.
The game is loaded with all the code from the index.html + JavaScript files (loading.js etc).

I have a script file for an entity in my game.

When i came back on the game screen twice, i have this error :

“Uncaught SyntaxError: Identifier ‘DistributeCoins’ has already been declared”

DistributeCoins is a const inside my script. Is it possible to not preloading twice assets ?

Hi @vogloblinsky,

Can you share some details on how you boot the PlayCanvas app from Angular?

With the behavior you describe it seems like the pc.Application instance is loaded twice or the component initialization code runs twice.

Like in this project :

But in this example there is no script attached to an entity.

In my project, when the view is destroyed, i also destroy pc Application.