- Home /
[AssetsBundle] How to keep an AssetBundle on device after the download
Hi everyone,
My question is quite stupid : Where did my assetBundle go when i downloaded it? I've spent a few hours on different forums, and it seems it's sotcked in the unity cache in AppData/LocalLow/Project. But i've got nothing (got the project folder, but not my data inside it). My downloading is working properly, and i can use the assets, but I can't keep track of my bundle so everytime i need it Unity will redownload it.
My purpose is to :
check if the user have the bundle
check if the user have the right version of the bundle
update his bundles by download them
use the bundle in unity by calling the local path on windows/android/iOS
Can't find any answer to this, since i can't call it again locally if needed after download . Furthermore, I need to keep the data of the bundle for a next game session, I don't want them to be cleaned all the time.
Thanks in advance if you have any answer or tips for me.
Sample of the code I'm using (this works):
IEnumerator DownloadFromFile() { UnityWebRequest request = UnityWebRequest.GetAssetBundle(onlinePath, 0); yield return request.Send(); AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request); if (bundle == null) { Debug.Log("Failed to download AssetBundle!"); yield break; } myClassItems = bundle.LoadAllAssets<MyClass>(); }
Answer by FlaSh-G · Jun 20, 2017 at 04:38 PM
Don't mind caching yourself, use WWW.LoadFromCacheOrDownload because that's what it's for!
Thanks for your answer, but I know about this, and it's tagged deprecated :/ So I would prefer using the new and recommanded methods.
I don't see where it's marked as deprecated - neither in the scripting reference, nor in autocompletion. I'm on 5.6.1. Either way: If something is marked as obsolete in Unity, it's also usually giving a comment on what to use ins$$anonymous$$d.
see here https://docs.unity3d.com/$$anonymous$$anual/AssetBundles-Native.html
TO BE DEPRECATED (Use UnityWebRequest)