Hello!
I spent hours trying to achieve what I want, but it doesn’t want to work.
I’m trying, to Resources.Load() an image from my Resources directory and display it on an Image then.
This works, prints “Texture loaded”:
var texture = Resources.Load<Texture>("Categories/Matchsticks/1");
if (texture != null) {
print("Texture loaded");
}
else {
print("Missing image file");
}
So yes, the path is correct, the file is present. But… This doesn’t work, prints “Missing image file”:
var texture = Resources.Load<Texture2D>("Categories/Matchsticks/1");
if (texture != null) {
print("Texture loaded");
}
else {
print("Missing image file");
}
The only difference is Texture to Texture2D
I need to load that texture in order to create a Sprite (Sprite.Create(Texture2D, Rect)) and display the image, on Unity, Android and IOS, explaining why I use the Resources folder and Resources.Load()
I did try with other methods, they all fail
var texture = Resources.Load("Categories/Matchsticks/1", typeof(Texture2D));
var texture = Resources.Load("Categories/Matchsticks/1", typeof(Texture2D)) as Texture2D;