1. Nir say:

    Hi Sergey, thank you for your thorough explanation. I have a similar problem that I’m not sure how to solve:

    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:
    var AssetBundle bundle_C1_Back = AssetBundle.CreateFromFile(“Assets/Bundles/C1_Back.unity3d”);
    var Object[] c1_Back = bundle_C1_Back.LoadAll(Texture);

    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[i] = request.asset;

    Thanks in advance, appreciate the help.

    • Jan say:

      Hi Nir,
      little late answer but:

      if you start a coroutine in Awake or OnEnable Unity will not load async. I suppose this is a bug. A simple “yiel return null;” at the beginning of your coroutine will fix this.

      Maybe even Start triggers this kind of behaviour.

      Cheers :)

  2. Ilan say:

    Hello Sergey, very interesting article, there is almost no information about implementation of asset bundles. Is it possible to get the .cs for downloading the asset bundles to the project?

    In that case I will give you my email address. I need something similar for a project I am developing.

    Thank you very much, best regards!

Write a comment