- Home /
Resource.Load always return null
Hello!
I'm new on Unity, Im trying to change the Material in C#, so I dont need to recreate the renders. The problem is Resources.Load ALWAYS return NULL, how can I get the Material?
I'm attaching mi Unity project and the Mono Project screenshot.
Answer by ArkaneX · Sep 05, 2013 at 02:12 PM
In order properly use Resources.Load method, your resources must be inside Assets\\Resources folder. You need to create Resources folder and copy/move Materials folder into it. Additionally, according to documentation, path passed to the method must be relative to Resources folder, so in your case must start with Materials...
For me, it doesn't work... Any other ideas? The file exists, and I tried importing into Object, Gameobject, $$anonymous$$esh, etc. It is a .obj file
This prints yes:
if (File.Exists("Assets/Resources/Characters/1/1.obj"))
{
Object x = Resources.Load("Characters/1/1.obj");
if (x == null) print("Yes");
}
Answer by Jamora · Sep 05, 2013 at 02:09 PM
You can only load assets using the Resources-class if the assets you're trying to load are in a Resources folder.
All Assets in any Resource folder are automatically included in the build, so don't keep unneeded stuff there.