Getting Resources Folder

Hi Everyone!

I’m struggling to find a solution for this, i’m aware that in the builded game there is no “Resources” folder, but have some structures there i need to list the name of my assets

Resources/Cars/Tier1
Resources/Cars/Tier2
Resources/Cars/Tier3

Inside each folder i have a series of scriptable objects for car models.

I need to find a way to get the name of the files on each directory so i can later do a "Resources.Load(Cars[index]);

i was thinking in getting al the list of files trough System.IO of .net, but i dont know how can i reference the resources folder.

Any hints on this would be a great help!!!

Thanks in advance.

The Resources folder in the editor gets baked into a binary file in the build. There is nothing that System.IO can do to give you the data that the binary file contains. Be better to write an editor script that rounds up all the names of the files in Resources, and writes that as a text file into the Resources folder. Then you can load that text file using Resources.Load and then have all the data you need.

1 Like

Ou :frowning: i was afraid of that.

Thanks! i’ll go with the editor option, and save all my files names in editor time so i can read it later. Thanks!!

Ya a co worker of my wrote a editor script that searches through the resources folder and maintains a json file that lists all the files in it.

Are you loading prefabs, or trying to load an actual c#/js script from the resources folder? If you’re trying to load an actual script, there’s no reason to have it in the resources folder, they should be just in the scripts folder, where you’d access them through their class name, preferably in their own namespace.

Part of the problem here is your ambiguity about what you’re trying to accomplish. There may be a far better approach. For example, if you want to be able to just plug in different cars without modifying scripts, you could do what you want through serialization and loading an XML file that describes the characteristics of your different cars, rather than having a seperate script for each car.

I have my own Custom Assets generated by ScriptableObjects (a file with .asset extension)
and i just need the list to all of that files i have in my folder