Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Resource.LoadAllAsync - where is it?

Discussion in 'Scripting' started by laurentlavigne, Dec 6, 2016.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    1,949
    We have LoadAsync, cool, now LoadAll definitely takes longer so async on this one would make sense yah?
    So where is it.
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,648
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    1,949
    Bundles require to export them to external files and you need a bunch of boilerplate code to handle them in editor, right?
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    12,298
    Kiwasi likes this.
  5. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    1,949
    read the post - LoadALLAsync
     
  6. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    12,298
    You're asking for it to load the entire resources folder, correct? It clearly states it does that if you pass an empty string.
     
    Kiwasi likes this.
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,648
    Lol. When in doubt, read the manual. Can't believe I missed that.
     
  8. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    1,949
    ResourceRequest.asset returns only one object no?
     
  9. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,291
    I imagine you'd cast it to an Object[].
     
    laurentlavigne likes this.
  10. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    15,648
    Why not try it and see? You could answer that more accurately and faster by simply opening Unity.
     
  11. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    1,949
    I didn't know you could cast an Object to an Object[] so I tried () and "as" and nope it doesn't compile.
    So I did my own soup casting the result to IEnumerable and building the list.
    .asset is null, what am I doing wrong?

    Here is the code.
    Code (CSharp):
    1.     public List<GameObject> objects = new List<GameObject>();
    2.     IEnumerator Start () {
    3.         var timer = Time.time;
    4.         var resourceLoad = Resources.LoadAsync ("", typeof(GameObject));
    5.         yield return resourceLoad;
    6.         Debug.Log (Time.time-timer);
    7.         if (resourceLoad.asset.GetType ().IsArray) {
    8.             var objs = (IEnumerable)resourceLoad.asset;
    9.             foreach (var o in objs)
    10.                 objects.Add ((GameObject)o);
    11.         }
    12.     }
     
  12. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    1,949
    Got a reply from Unity QA it's a bug and sent for resolution. Let's see if resolution turns out to be removing the bit in the documentation ;)
    bug# 858737