Reputation: 1731
I'm trying to load a Texture
from the Resources
folder but it keeps on returning null
.
t = (Texture)Resources.Load("Circle") as Texture;
The circle texture has an extension of .tga
.
Upvotes: 2
Views: 10350
Reputation: 11
@Massimiliano Uguccioni thanks... that fixed my problem.
Steps to use Resources.load:
Upvotes: 1
Reputation: 2139
Texture File should be added into Resources folder After that use below lines of code for load texture
var Texture_1 : Texture2D;
Texture_1 = Resources.Load("TextureName");
Folder should be in kept into Resources folder After that use below lines of code for load folder of textures
var textures : Object[];
textures = Resources.LoadAll("FolderName");
Upvotes: 2
Reputation: 151
The extension of the file isn't necessary. So this is correct:
t = (Texture)Resources.Load("Circle") as Texture;
This is not:
t = (Texture)Resources.Load("Circle.npg") as Texture;
Upvotes: 2
Reputation: 373
You must put Circle.tga in Assets/Resources folder. Plus if you have subfolder, for example Resources/Textures/Circle.tga then do like this:
Texture t = Resources.Load("Textures/Circle") as Texture;
Upvotes: 2