Cinder-AssetManager
Cinder-AssetManager copied to clipboard
Ability to unwatch an asset
Hey Simon,
I've been using this block for a couple months now and it has been serving me well, thanks for this contribution! I think I've hit something that I need to somehow overcome for my current project - the ability to unwatch an asset.
Basically, I have many dynamic objects, some with shaders or other resources that are watched and live updated by AssetManager. The problem is that during the app's lifetime, I can reload and I not only don't care about some of the assets, I'd like their callbacks to stop firing. However I don't think there is a way to remove a Loader after its been added.
Hi Rich,
Indeed, this is something missing from the api. I guess there would be several way of implementing this, the two first that come to my mind would be AssetManager::unload( fs::path, ... ), more or less same api but doing the opposite... We could also return a LoaderRef reference from the load functions. Something like LoaderRef AssetManager::load( ... ) and have methods like watch/unwatch in the loader class.
On the other hand, I've been using node.js lately and I have to say that the way they implemented this in their filesystem api is really sweet, it might be worth just re-thinking the whole block...
Let me know what you think.
edit: I just had a look and boost::fs + boost::asio extension could be a nice solution to implement a cleaner api... I'll see in the next few days if I can do something.
Hi Rich,
Have a look here: https://gist.github.com/simongeilfus/972f57d7b1a0e3d39156 I'm thinking about updating the block with a new design. I'm still trying to figure out the best way but I quite like this first version. It's still a bit buggy but the idea is there, and it is a one header only lib, so it should be easy to test.
Anyway I think the new design is at least fixing the issue you're mentioning above.
Let me know what you think!