Search Unity

  1. Unity 2018.3 is now released.
    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. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Resource.LoadAllAsync - where is it?

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

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    2,011
    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:
    16,076
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    2,011
    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,881
    Kiwasi likes this.
  5. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    2,011
    read the post - LoadALLAsync
     
  6. Ryiah

    Ryiah

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

    laurentlavigne

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

    makeshiftwings

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

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,076
    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:
    2,011
    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:
    2,011
    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