Resources.Load returns null in a build, but works in the editor

Hello Everyone,

I recently updated my project with a new high res art and I am experiencing a problem now. Resources.Load returns null in a build, but works in editor. I tried builds for Windows and Mac that were built using 3.4.2 and 3.5.2.

When I remove half of art files from Resources folder builds are working perfectly. Also I reimported all assets a couple of times and it didn’t help.

It would be great to get some direction or hear your thoughts about this problem. Any help will be appreciated.

For example I have a test script that executes perfectly in the editor, but doesn’t work in a build.

if (Resources.Load (“Images”) != null){
Debug.Log("Images.xml is loaded! "); // executes in the editor
}else{
Debug.LogError("Can’t find Images.xml! "); // executes in a build
}

Thank you very much,
Nikita

1 Like

Is there any reference pointing to your resource? All resources are deleted from the builds, unless they are somehow referenced. As far as I know, objects from any scene of the build, objects that are referenced by those are part of the build only. You may try to add a dummy game object with a script that simply exists to have the references to those files you are trying to load. Hope it helps.

Assets in the Resources folder are exempt from that; they’re all included in the build regardless of whether you’re using them or not.

Not sure if .xml is an accepted and supported format in which case Unity won’t include it in builds either.

.txt (and .xml.txt) is recognized as text asset and could be used as a text asset though

same Problem Here , i doubt it to be a bug .

the image just sum it up , previews both editor and build → [High Graphic settings]

i had to submit this followup because the problem was from my custom shaders and not the Resources.load

@nickmarty

try type casting
[Resources.Load (“Images”) as TextAsset]

Just had the same problem : Resources.LoadAll in Awake fails to load if there’s too much data(but works in the editor). In my case, 49 100k files and 49 1mb files : only the former was loaded. The latter did return an Object[ ], which was cast to the right type: no errors, nothing amiss except missing data…

Shifting Load from Awake to Start and yielding between the two calls solved the problem for me.

Will file a bug report.

G

The same problem in 2021, our CI doesn’t work because we try to keep configurations in scriptable objects in resources folder