Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Loading all AssetBundle content Asynchronously

Discussion in 'Editor & General Support' started by johnsmith954, Jun 12, 2014.

  1. johnsmith954

    johnsmith954

    Joined:
    May 14, 2014
    Posts:
    3
    Greetings,

    I'm trying to load an image sequence into a scene asynchronously. What I would like to do is play a video while the assets are being loaded. At first I was using Resources.Load but then I realized it was freezing the video (and app) until it finished loading. I decided to try loading the images through an asset bundle because of the async feature. I created an uncompressed asset bundle out of the sequence, stored it locally, and then assigned it using CreateFromFile. Now, in order to load all the textures that are in the bundle to a variable array, I tried to options:

    1. Using LoadAll() to load all the textures to my Object[]. Although it loaded, it did NOT load the images asynchronously. So the app was still freezing up until all the images were loaded.
    2. Using LoadAsync, I created a for loop that cycles through the contents of the bundle and loads it one by one using the asynchronous call LoadAsync. This, however, was also freezing up the app for a few seconds. It was not loading asynchronously. Is it because of the loop?

    How would I go about loading all the contents of the AssetBundle asynchronously? Is it possible using AssetBundles? If not, is there another tool I could use to achieve this?

    Here are examples of the two codes:
    1.
    var AssetBundle bundle_C1_Back = AssetBundle.CreateFromFile("Assets/Bundles/C1_Back.unity3d");
    var Object[] c1_Back = bundle_C1_Back.LoadAll(Texture);

    2.
    var AssetBundle bundle_C1_Back = AssetBundle.CreateFromFile("Assets/Bundles/C1_Back.unity3d");

    for(var i = 0; i < numberOfImages; i++)
    {
    AssetBundleRequest request = bundle_C1_Back.LoadAsync(c1_Back_Name + i.ToString("_00000"), Texture);
    c1_Back = request.asset;
    }


    Thanks in advance, appreciate the help.
     
    Last edited: Jun 12, 2014
  2. Wothanar

    Wothanar

    Joined:
    Sep 2, 2016
    Posts:
    122
    No one answear you? damn and this is old... im searching about this now and im so disappointed with unity , my boss its want to go to unreal engine now coz unity start to give us limit on 4gb texture and those assets bundles without documentation on how to load them all the content damn
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,414
  4. Wothanar

    Wothanar

    Joined:
    Sep 2, 2016
    Posts:
    122
    Its out of date the tutorial and sample proyect give errors
    thanks anyways... i figure out how to work with assets bundles using assets bundles browser , still im mad coz unity is acting weird , when im going to build and assets bundle its take tooo loooooooong it start to reimporting data hashes calculating and calculating and waiting and waiting just for made a damn light assets bundle with a few textures on it... i dont know why this start to reimport things for the plataform i didnt change the plataform its windows ... standalone ... but well i had to wait centurys for unity its start to frustrating me all of this becouse i had to change almost all the game for use assets bundle since unity had a 4gb texture limit that just SUCKS !