What is the best way to load a set of sprites and be able to reference them later?

I want to have a set of sprites within a folder, and then be able to reference them from a dictionary by giving each of them a number. I want to do it like this so that I can have a variable for “Stance” that tells if the character is crouching, standing, or jumping, and will then add the stance plus the sprites number to get a resultant sprite number. So a punch might start on frame Sprite_05, but the jumping punch would start at Sprite_15. There is probably a better way to do this, and Im open to ideas.

Currently Im struggling to make DirectoryInfo work, because thats what ive found on these forums so far.

Can someone tell me where to start with something like this?

Better way is to make prefabs out of what you need. This lets you add custom knowledge at editor time when a) you can check it, and b) performance isn’t a consideration.

Then in the game just load or switch to whatever you need. Animation is extremely well-covered in tutorials.

It will never work. The entire directory structure in your project is obliterated and the assets selected to go into your build are “baked” into another format tailored to performant loading on whatever target you’re on.

You may be able to use Resources.Load() or Resources.LoadAll() to dynamically load content out of your game, but again, that is very fiddly and code- and organization-centric. It’s always better to simply make the parts you need, then load those parts.

If you go with Resources.Load(), be sure to start with the docs or you’ll waste a lot of time.

you should first zip everything and put the zip in the streaming assets folder

then you should make a script that when the game starts unzips that and sends the contents to persistentdatapath

persistentdatapath is a folder that can be conveniently used with directoryInfo

now you can use directory info on persistent data path + your sprite location

you will have to do extra things like load them as image, then as texture, then sprite.create() but thats how you would do it if you go that route