Hello,
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

Hello,
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

I dont think so you can do ‘as Texture’. Casting it with ‘(Texture)’ should work.
See the MSDN documentation to know differences between ‘is’, ‘as’ and () types casting in C#. Its confusing in the beginning.
I also belive that the as-cast might be the problem, but in addition, like @Yokimato mentioned, you should use the Load function that takes a type parameter. You almost never need the type "Texture", in 90%+ of all cases you want to use Texture2D
– Bunny83
Not that I think it's the issue, but you're doing some overkill on the type casting. Remove the
– Yokimato(Texture)type cast from the line once since you're already using theaskeyword, which almost does the same thing .... but not really. In either case, having both probably isn't a good idea.And your "Circle.tga" file is in the top level of your Assets/Resources folder?
– whebertYes it is.
– NewPersonaSo, just verifying, the path to your file is Assets/Resources/Circle.tga? That should work.
– whebertThat is indeed the path, I even checked the spelling of everything.
– NewPersona