Search Unity

  1. Unite Berlin 2018 schedule is now updated with talks on real-time ray-tracing, upcoming 2D features & many more. Check it out!
    Dismiss Notice
  2. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  3. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  4. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    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,828
    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:
    14,983
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    1,828
    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:
    11,344
    Kiwasi likes this.
  5. laurentlavigne

    laurentlavigne

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

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    11,344
    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:
    14,983
    Lol. When in doubt, read the manual. Can't believe I missed that.
     
  8. laurentlavigne

    laurentlavigne

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

    makeshiftwings

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

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    14,983
    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,828
    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,828
    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