I have around 200 sprites (jpg pictures) in Assets>Textures>Pictures
, and I have GameObject
with <SpriteRenderer>
. Is there a way for me to load sprites from that folder into this GameObject
in code?
Something like Resources.Load<Sprite>("path");
Thank you.
Put your folder inside the Resources folder. Like this: Assets/Textures/Resources/
Then you can do this:
private Object[] textures;
void Awake()
{
textures = Resources.LoadAll("Path");
}
You have to store them as Objects
. However, if you want to use them later you can do something like this.
texture = textures[i] as Texture;