{"action":"created","issue":{"url":"https://api.github.com/repos/playcanvas/engine/issues/440","labels_url":"https://api.github.com/repos/playcanvas/engine/issues/440/labels{/name}","comments_url":"https://api.github.com/repos/playcanvas/engine/issues/440/comments","events_url":"https://api.github.com/repos/playcanvas/engine/issues/440/events","html_url":"https://github.com/playcanvas/engine/issues/440","id":117380361,"number":440,"title":"Reference-counted Assets","user":{"login":"PsichiX","id":2111867,"avatar_url":"https://avatars.githubusercontent.com/u/2111867?v=3","gravatar_id":"","url":"https://api.github.com/users/PsichiX","html_url":"https://github.com/PsichiX","followers_url":"https://api.github.com/users/PsichiX/followers","following_url":"https://api.github.com/users/PsichiX/following{/other_user}","gists_url":"https://api.github.com/users/PsichiX/gists{/gist_id}","starred_url":"https://api.github.com/users/PsichiX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PsichiX/subscriptions","organizations_url":"https://api.github.com/users/PsichiX/orgs","repos_url":"https://api.github.com/users/PsichiX/repos","events_url":"https://api.github.com/users/PsichiX/events{/privacy}","received_events_url":"https://api.github.com/users/PsichiX/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/playcanvas/engine/labels/feature%20request","name":"feature request","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-17T15:34:58Z","updated_at":"2015-11-17T15:52:13Z","closed_at":null,"body":"Hi!\r\n\r\nWhat about using reference-counted assets feature to better handle Asset lifecycle (for example: loading assets only when they are needed and unloading them when they are no more needed (there is not any asset reference bound to given asset))?\r\nTake a look at my proposition of reference-counted assets feature (that already exists in one of my projects, it's tested and works well):\r\n\r\nhttps://gist.github.com/PsichiX/a0e6efdb9920fe58e39b\r\n\r\nRight now i have to use hand-written plugin that hooks into PlayCanvas to solve that but it cannot be so simply integrated with all assets pipeline so it will be better if Assets pipeline will be able to handle reference-counted assets life-cycle :)\r\n\r\nCheers! ^^\r\n\r\nBtw. how to assign proper labels to this 'issue'? :D"},"comment":{"url":"https://api.github.com/repos/playcanvas/engine/issues/comments/157410956","html_url":"https://github.com/playcanvas/engine/issues/440#issuecomment-157410956","issue_url":"https://api.github.com/repos/playcanvas/engine/issues/440","id":157410956,"user":{"login":"Maksims","id":636263,"avatar_url":"https://avatars.githubusercontent.com/u/636263?v=3","gravatar_id":"","url":"https://api.github.com/users/Maksims","html_url":"https://github.com/Maksims","followers_url":"https://api.github.com/users/Maksims/followers","following_url":"https://api.github.com/users/Maksims/following{/other_user}","gists_url":"https://api.github.com/users/Maksims/gists{/gist_id}","starred_url":"https://api.github.com/users/Maksims/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Maksims/subscriptions","organizations_url":"https://api.github.com/users/Maksims/orgs","repos_url":"https://api.github.com/users/Maksims/repos","events_url":"https://api.github.com/users/Maksims/events{/privacy}","received_events_url":"https://api.github.com/users/Maksims/received_events","type":"User","site_admin":false},"created_at":"2015-11-17T15:52:13Z","updated_at":"2015-11-17T15:52:13Z","body":"What if asset is not used, but needs to be held loaded, as player goes through level, and that monster will come up at some point?\r\nIt is more of a game specific behaviour. We need to think of flexible API that allows to make it simpler.\r\n\r\nCurrently finding our if asset is used or not - useful, but if API allows to be avoided (using id directly instead of AssetRef), then it is prone to human mistakes.\r\n\r\nUnloading is possible, and in most cases currently done by using Tags, where people load whole bunch of assets tagged lets say `level-1`, and then unload them as they need to."}}