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

Resources.LoadAll<T>(Path) loads everything...

Discussion in 'Scripting' started by LightStriker, Sep 24, 2014.

  1. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    I got myself a little shortcoming on Unity here...

    I'm using http://docs.unity3d.com/ScriptReference/Resources.LoadAll.html

    I found out it load EVERY object in the supplied path, even those that are not of the proper type. The method only returns the proper supplied type, but in background, all the wrong types are still loaded and initialized.

    It's very bad for load time and memory consumption. Do I understand Unity is unable to know the types in a file without loading ALL of it? (no header)

    Do I have an alternative?
     
  2. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Is it an issue only with the generic overload or also the overload that takes a Type?
     
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Same behaviour with both method. In background, the generic one calls the non-generic and simply perform an array conversion.

    I'm also worry this issue would plague the AssetBundle.LoadAll method.