Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by zarnes · Apr 27, 2018 at 12:50 PM · assetassetscachebundlebundles

The AssetBundle can't be loaded because another AssetBundle with the same files is already loaded.

Hi, I'm trying the assetbundle and it's awesome ! I can build a very light game and only load the assets I need. But if you don't use cache, it quickly become useless ! I started just by loading the assets and drop them when I closed the game. The loading code without cache code :

 request = UnityWebRequest.GetAssetBundle(url, 0); // Work with that method : always download
 UnityWebRequestAsyncOperation op = request.SendWebRequest(); // Set the request
 while (!op.isDone) ; // Wait for download    
 bundle = DownloadHandlerAssetBundle.GetContent(request); // Get the bundle
 return bundle.LoadAsset(asset); // return it

This is working perfectly, all my assets are correctly loaded, I can even load the same asset from the same bundle multiple times, with a simple dictionary check I can avoid multiple downloads. But now I want to make serious business ! I thought that caching was already done but I saw that it wasn't when I tried with my android in plane mode.

So I refactored a bit my code :

 public Object LoadSync(string bundle_name, string asset)
 {
     AssetBundle bundle = null;
     if (!bundles.TryGetValue(bundle_name, out bundle)) // Test if I already downloaded the bundle
     {
         // Build my url, nothing special
         string url = asset_server_name + "/" + bundles_path + "/" + platform + "/" + bundle_name;
 
         UnityWebRequest request;
         if (allow_cache_loading)
             // search in cache then download : doesn't work with that method
             request = UnityWebRequest.GetAssetBundle(url, 1, 0); 
         else
             // always download : work with that method
             request = UnityWebRequest.GetAssetBundle(url, 0); 
 
         UnityWebRequestAsyncOperation op = request.SendWebRequest(); // Set the request
         while (!op.isDone) ; // Wait download
         
         bundle = DownloadHandlerAssetBundle.GetContent(request); // Get the bundle
         bundles.Add(bundle_name, bundle); // Add the bundle to the list
     }
     
     // Return the asset
     if (bundle != null)
         return bundle.LoadAsset(asset);
     else
         return null;
 }

What is strange is that my first bundle load perfectly, as long as I load something from this first bundle, thanks to my condiction, it works. But as soon as I want to load from another bundle I get the the error : Error while getting Asset Bundle: The AssetBundle 'bundle' can't be loaded because another AssetBundle with the same files is already loaded.

What I tried : - A lot of my bundles are just a single file named default.png, so I tried to change filenames, I still get the error. - I looked at the request variable, not a single time it had any error boolean to true. - I looked at the request response code, for the first asset loading, it's 200 if I cleared my cache before, 0 if I didn't which is perfect, but for the next bundles loading, the response code is 0, even if I cleared the cache, the rest of the error booleans are normals, and the bundle property is null (yay fetched null from cache). So I'm wondering why the UnityWebRequest is looking in the cache if the value is null ! - My assets where organised as a tree to ease my workflow, all my characters assets where placed in the bundle characters/name/2d, so I though that if I had 2 characters, I would have 2 bundles named characters/char1/2d and characters/cha2/2d, which would be completely independent. It seems to be the case with the download only version, but for the caching version, it doesn't. I believe that there is only one bundle considered : characters, which contain char1 and char2. That's not great but if I name all my bundle differently without "/", it works.

I have to precise that the folders containing my assets are not in the bundles.

So ! My final question is Can we get rid of this message with an assetbundle hierarchy ?

Thanks (and congrulation) for reading my text :D

TDLR : Can I use a hierarchy for my assetbundle with cache ?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by nishugu2 · Feb 22, 2019 at 09:03 AM

CanYou get any solution of this because i also got this and i have no solution

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by NareshKhandla · Mar 19, 2019 at 11:20 AM

//"I have resolved this problem using add below lines"

private AssetBundle myLoadedAssetBundle; string bundleUrl=""; IEnumerator LoadAssetBundle () { if (myLoadedAssetBundle != null) { myLoadedAssetBundle.Unload(false); //scene is unload from here }

while (!Caching.ready) yield return null;

WWW www = WWW.LoadFromCacheOrDownload(bundleUrl, 1); yield return www;

if (!string.IsNullOrEmpty(www.error)) { Debug.Log(www.error); yield return null; } myLoadedAssetBundle = www.assetBundle; }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

84 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Cannot download large assetbundle with WWW.LoadFromCacheOrDownload on old iOS device 1 Answer

[AssetsBundle] How to keep an AssetBundle on device after the download 1 Answer

Bundle Cache Size 0 Answers

Asset Bundle mismatch keeps returning. 2 Answers

I keep losing my assets 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges