- Home /
Resources does load up in the editor but not in build
Before Unity 5, I could load up the assets in Resources folder by using Resources.Load command. It was calling the 2D Texture assets in Resources folder successfully (Both in build and editor).
Then I upgraded my project to Unity 5, made a few graphical changes in the project. This time my application runs in the editor perfectly, but not in the build. The textures in the Resources folder return as null (only in the build). I could not solve this issue and find a solution for this problem.
My code when I call Resources is below:
if (colorscheme.Equals(0))
{
texture0 = Resources.Load("cliff_layrock") as Texture2D;
texture1 = Resources.Load("grass_hill") as Texture2D;
texture2 = Resources.Load("grass_mea") as Texture2D;
}
Note that, I am sure of all the textures are available in the Resources folder and it was working before Unity 5 perfectly. Also, I am building a x64 Windows application.
Have you tried this way? For resources folder:
Resources.Load<Texture2D>(string path);
Resources.LoadAsync<Texture2D>(string path);
Alternatively for any folder you can use:
Resources.LoadAssetAtPath<Texture2D>(string path);
P.S. Don't forget about the file extension.