Unity Community

Register or Sign In:

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 21

  1. Location
    San Diego, CA
    Posts
    43

    Failed to load asset bundle

    Thanks for any help in advance!
    I have a basic assetbundle project where I use my custom UnityEditor scripts to compile a simple Box and Texture2D into a single prefab assetbundle named "iphone-prefab-box.assetbundle".

    Everything compiles and runs fine within the Unity 3.3 environment:

    Code:  
    1. private WWW www;
    2. IEnumerator Start () {
    3.     String strPath = "file://" + Application.dataPath + "/../assetbundles/iphone-prefab-box.assetbundle";
    4.     Debug.Log(strPath);    
    5.     www = new WWW(strPath);
    6.     yield return www;
    7.     AssetBundleRequest request = www.assetBundle.LoadAsync("Box", typeof(GameObject));
    8.     yield return request;
    9.     Instantiate(request.asset, new Vector3(3f, 0f, 0f), Quaternion.identity);
    10.     Instantiate(request.asset, new Vector3(0f, 0f, 0f), Quaternion.identity);
    11.     Instantiate(request.asset, new Vector3(-3f, 0f, 0f), Quaternion.identity);
    12. }

    When I cross-compile and run this in XCode on an iOS device I get the following error:

    file:///var/mobile/Applications/2A782E51-DD70-4F3B-970A-C030C84258E4/test1.app/Data/../assetbundles/iphone-prefab-box.assetbundle

    (Filename: /Applications/buildAgent/work/6bc5f79e0a4296d6/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 2505)

    -> force accelerometer registration
    -> applicationDidBecomeActive()
    Failed to load asset bundle

    (Filename: /Applications/buildAgent/work/6bc5f79e0a4296d6/Projects/../Runtime/Misc/AssetBundleUtility.cpp Line: 104)
    I've included the "assetbundles" directory into my XCode project as well. I'm probably missing something simple here! Any ideas guys?

    Name:  Screen shot 2011-05-03 at 8.04.15 AM.png
Views: 1504
Size:  320.2 KB
    Last edited by danielsonchris; 05-03-2011 at 09:22 AM.


  2. Posts
    65
    same problem I have....


  3. Location
    San Diego, CA
    Posts
    43
    Well I've gotten past the "Failed to load asset bundle" error now. I simply copied my prefab into the Data folder using the Terminal and that fixed everything up.
    cp my-prefab.assetbundle /Users/<user account>/Documents/projects/unity/MPLib/iOS/Data


    Now I'm getting a new error:

    -> applicationDidBecomeActive()
    The file can not be loaded because it was created for another build target that is not compatible with this platform.
    Please make sure to build asset bundles using the build target platform that it is used by.

    (Filename: /Applications/buildAgent/work/6bc5f79e0a4296d6/Projects/../Runtime/Serialize/SerializedFile.cpp Line: 210)

    The asset bundle 'file:///var/mobile/Applications/2A782E51-DD70-4F3B-970A-C030C84258E4/test1.app/Data/iphone-prefab-box.assetbundle' can't be loaded because it was not built with the right version or build target.

    (Filename: /Applications/buildAgent/work/6bc5f79e0a4296d6/Projects/../Runtime/Misc/AssetBundleUtility.cpp Line: 58)



    I'm going to try and rebuild the prefab now using my script after I change the Unity engine to use the iOS build. I'll report my results here when I'm finished.


  4. Posts
    65
    rather than manually copying the prefab, have you try to write it to cache? and read from it? using your current method see if it works?


  5. Location
    San Diego, CA
    Posts
    43
    Fixed! Everything is working like a champ now. OK, here is what I did to fix that last error:

    Changed this line of my UnityEditory script:
    BuildPipeline.BuildAssetBundle(null, assets.ToArray(), path, BuildAssetBundleOptions.CollectDependencies);

    Changed to:
    BuildPipeline.BuildAssetBundle(null, assets.ToArray(), path, BuildAssetBundleOptions.CollectDependencies, BuildTarget.iPhone);

    Everything works great here now. The project runs without crashing and I can see my instantiated assets on the iOS (iPhone 4).
    Last edited by danielsonchris; 05-03-2011 at 09:53 AM.


  6. Location
    San Diego, CA
    Posts
    43
    Quote Originally Posted by TigerShan View Post
    rather than manually copying the prefab, have you try to write it to cache? and read from it? using your current method see if it works?
    I see the thread you are referring to now. http://forum.unity3d.com/threads/878...Bundle-Problem

    I'm going to take a guess that on your second click of the download asset button, the code is incorrectly detecting the cache. You're probably going to need to insert in more Debug.Log statements around your code including making sure that the file paths are 100% accurate. I would do a file system check and not rely on a download flag as well. Just my 2 cents.


  7. Location
    San Diego, CA
    Posts
    43
    Wanted to clarify something here as well. You do not need to use the Terminal and copy your assets into the Data folder, etc. Instead, you would want to do the following.

    Drag your "assetbundles" or whatever the folder name is onto the root of your XCode project and then select as shown in the attached screenshot.

    Name:  Screen shot 2011-05-03 at 10.53.56 AM.png
Views: 1484
Size:  234.0 KB

    This then will load perfectly using the following path code:

    Code:  
    1. String strPath = "file://" + Application.dataPath + "/../assetbundles/iphone-prefab-box.assetbundle";


  8. Posts
    104
    Hi everyone,

    I'm just trying to include assets bundles in my ios app, just like in this example, but it does not work.

    It works in Unity editor, but when I add my bundle directory in the xcode as done there, ( the directory appears correctly at the root in the .app file with all asset bundle files inside ) and launch the game on my Iphone3G, it just does not work.

    Any idea?


  9. Location
    San Diego, CA
    Posts
    43


  10. Location
    Montreal, Canada
    Posts
    1,437
    You can automate much of the transfer process with a folder named Assets/StreamingAssets.

    In Editor it's located as Application.dataPath + "/StreamingAssets/" and on device it's located at Application.dataPath + "/Raw/".

    Unity automatically copies it as a build process into your XCode project and .app bundle.


  11. Posts
    104
    Great, i'll give it a try and let you know.

    Thanks all !!!


  12. Posts
    104
    Still does not work, but data are well placed in RAW .app folder.
    Maybe there's something wrong in my code.

    Here's what I do in the Start of my GameObject :
    WWW www = new WWW("file://" + Application.dataPath + "/Raw/" + name + ".asb");
    yield return www;

    // Load asset texture.
    Texture2D inter = www.assetBundle.Load(texture) as Texture2D;
    mat.SetTexture("_MainTex", inter);
    www.assetBundle.Unload(false);

    Any idea?


  13. Location
    San Diego, CA
    Posts
    43
    Working through a resolution for this issue as well. Risine, are you using the latest Unity 3.4.2 release as well? I just updated to this version and noticed this issue occurring immediately. About 40 minutes ago I was using 3.4.1 and it was working fine. I'll keep you updated if when I find a solution.


  14. Location
    San Diego, CA
    Posts
    43
    Risine,
    When was the last time that you generated your asset bundles? My issue was stashed in the XCode logs:

    Invalid serialized file version. File: "none". Expected version: 3.4.2f2. Actual version: 3.4.1f5.

    The asset bundle 'file:///var/mobile/Applications/A2E2190F-7E45-4CF8-94A9-41734E60F99F/...../xxxx.monkeyprism' can't be loaded because it was not built with the right version or build target.
    I rebuilt my assetbundles and everything started working. Are you seeing anything in your XCode logs that can explain the situation further?


  15. Location
    Zürich, Switzerland
    Posts
    25,088
    an important second things on asset bundles, beside the version of unity, is that you also must target them at iOS. if the build script you have in the editor creates it for desktop it won't load on mobile and unless the error changed that would lead to an xcode error saying that its no valid asset bundle or similar


  16. Location
    San Diego, CA
    Posts
    43
    Risine, per Dreamora's statement, the editor call must specify the following bold statements at the very least to be loadable via iOS.
    In your build pipeline call:

    BuildPipeline.BuildAssetBundle(null, toinclude.ToArray(),
    path + assetFileName,
    BuildAssetBundleOptions.CollectDependencies,
    BuildTarget.iPhone);


  17. Location
    Düsseldorf Germany
    Posts
    287
    I got the following error when loading assert bundles:
    The asset bundle 'file:///var/mobile/Applications/CF849E49-8F28-4B8C-BFF9-DB6B7A5326C2/Catalogue.app/Data/Raw/Pages/Gesamtkatalog/page_00002.unity3d' can't be loaded because it was not built with the right version or build target.
    I know that the build target is set propper , i just updated unity and im not sure if thats what they mean with
    was not built with the right version
    Edit: ok rebuild the assert bundles in the new unity version works fine : Problem fixed.
    Last edited by Malzbier; 10-27-2011 at 02:19 AM.


  18. Posts
    104
    Ok, here are some info concerning my app :

    1/ I was on Unity 3.4.1f5, I am now on 3.4.2f2, but problems are the same. ( I created from scratch the bundles with the new unity version ).
    2/ To create the bundles, I'm using : BuildPipeline.BuildAssetBundle(null, objs, path + s1 + ".asb", BuildAssetBundleOptions.CompleteAssets, BuildTarget.iPhone);
    3/ I think the bundles are loaded on Iphone device ( in the Raw directory ) but I receive those warnings when launching the app :
    2011-10-27 10:53:48.769 MyApp[248:307] Received memory warning. Level=2
    WARNING -> applicationDidReceiveMemoryWarning()

    Therefore I suppose it 's some kind of memory issue, but as I said in a previous post, I'm not loading tens of Mb but hundred Kb, so that seems strange it does not work. ( it works when I use the Resources.Load() method instead ).


  19. Location
    Düsseldorf Germany
    Posts
    287
    I need to scrub through a catalog of 500 pages.
    Every page is 3mb im memory
    Im using a cashing system to get the new images before needed.

    I cash current 12 pages (2 for the current view and 5 in each direction) and 500 X 48kb thumbnails.

    The total object count is 1285 an the memory usage is at 288MB

    thumbnails: 500 X 48kb = ca 25MB
    +
    pages: 12 X 3MB = 36MB
    ======
    61MB
    Ok in addition i have 2 lowPoly models noting special.


    61MB for textures (lets say 70MB for menus items and so on) are someting different then 288MB.

    I need some tips to find the bad boys that are stealing my memory.


  20. Posts
    2
    Hi!
    I've similar problem but I'm trying to load an assetbundle from iOS App's Documents folder.
    This is the code:

    Code:  
    1. var urlFile = "file://" + GetiPhoneDocumentsPath() + "/savedassetbundle.assetbundle";
    2.     Debug.Log("---> loading file from: " + urlFile);
    3.  
    4.     downloadFile = new WWW (urlFile);
    5.  
    6.     yield downloadFile;
    7.  
    8. var assetBundleFile  = downloadFile.assetBundle;
    9. if(assetBundleFile==null)
    10. {
    11.     Debug.Log("---> file not found");
    12.     return;
    13. }
    14.    
    15. var go : Object = assetBundleFile.Load("Cube");
    16.        
    17.         if (go != null)
    18.         {
    19.             var instanced = Instantiate(go);
    20.                
    21.         }
    22.         else
    23.             Debug.Log("Couldnt load resource");

    and this is what i get:

    Code:  
    1. //I write this line from Debug console
    2. ---> loading file from: file:///Users/myusername/Library/Application Support/iPhone Simulator/5.0/Applications/AE459D8B-1511-4D07-8260-DD5117E08D8D/tmp/savedassetbundle.assetbundle
    3.  
    4. (Filename: /Applications/buildAgent/work/842f9557127e852/Runtime/ExportGenerated/iPhoneSimulatorPlayerUnityLib/UnityEngineDebug.cpp Line: 34)
    5.  
    6. -> force accelerometer registration
    7. -> applicationDidBecomeActive()
    8. Failed to load asset bundle
    9.  
    10. (Filename: /Applications/buildAgent/work/842f9557127e852/Runtime/Misc/AssetBundleUtility.cpp Line: 185)

    The filepath seems fine to me.
    Any ideas?