unity webgl, angular js directive,
So I am trying to use an angularjs directive to load a unity webgl game. I have it working but on reload it bombs out, my guess is that b/c I dynamically loaded 'UnityLoader.js' and then tried to reload it (say with a different game) it has global resources attached to the first game. Is there a way to unload the resources like with a javascript api call from my app?
It would be nice if we could have one 'UnityLoader.js' that we could configure to load and unload game resources.
Thanks
Answer by scotttrinh · Jan 29, 2016 at 03:44 PM
I'm working on the same thing myself, and I'm basically trying to un-global-ify the way the UnityLoader works. So far, I've made a service out of the main parts of UnityLoader to create a specific load() method on the service, and have it pass in the filename and module as parameters. This avoids the Module global object and having the name of the files as hardcoded values. I'll report back as I test out trying to unregister the thing.
Answer by farhankhwaja · Mar 12, 2017 at 05:03 PM
I tried working with a directive but I keep on getting some error. So, i moved away from directive and copied the index.html (genenrated by Unity) code and used it as a template.
With this approach I ma able to run Unity WebGL code with my AngularJS app, but as @scottrinh said ".. trying to unregister the thing.". even I am trying to unregister thing as I move away from the unity-webgl state to another and then re-register as I move back to unity-webgl state.
The unregistring of all variables/function etc is not as simple as I once thought. Hopefully somebody can shed some light on this.