- Home /
 
Resources.LoadAll stopped working since 2017.2
I used to load some resources using Resources.LoadAll(""). It worked fine from 5.0 to 2017.1 but since 2017.2 the resources are randomly not found.
I did not find a way to understand why sometimes it works and sometimes it does not.
Any idea?
I'm using it with no problem. Can you post your code please?
Thanks for your answer.
Here is what I do:
 ScreenshotConfigAsset[] objs = Resources.LoadAll ("");
 if (objs.Length == 0) {
         string path = "Assets/Resources/ScreenshotWindowConfig.asset";
         Debug.Log ("Creating new config file at " + path);
         m_ConfigAsset = ScriptableObject.CreateInstance<ScreenshotConfigAsset> ();
         AssetDatabase.CreateAsset (m_ConfigAsset, path);                
         AssetDatabase.SaveAssets ();
         AssetDatabase.Refresh ();
 } else {
        m_ConfigAsset = objs [0];
 }
 
 
                  $$anonymous$$aybe it comes from the fact that I then manually move the .asset file from "Assets/Resources" to a sub Resources folder like "Assets/$$anonymous$$yPlugin/Resources". The doc says it should work and most of the time the asset is found, but sometimes I see a new asset being created in the "Assets/Resources" folder.
I'm not sure about passing an empty string, but generally passing a path includes subfolders, so it should work. If it occurs randomly, there's something weird going on. I suggest using the generic version with a specific type, since you only seek for one type of assets.
Answer by itchyOwl · Feb 22, 2018 at 08:22 AM
 T[] instances = Resources.LoadAll<T>(pathUnderResources);
 
               Works for me.
Thanks for your answers. I was already doing it, but did not experience that issue since.
Answer by tormentoarmagedoom · Feb 22, 2018 at 08:13 AM
I always Use Resources.LoadAll like this:
 GameObject[] GameObjectsList = Resources.LoadAll (path) as GameObject;
 
               with the "as Gameobject" at the end to prevent wrong loadings.
I'm not sure if is this. Try it and give feedback!
 If was this, accept the answer!
 :D
 
              This won't compile, Resources.LoadAll()returns an array so can't be cast to GameObject 
Your answer