Resources.LoadAll on Current Folder Only?

When I use Resources.LoadAll on a folder called “Spawns” that has a child folder named “Structures”, it is also returning the GameObjects from “Structures”.

How can I make it only return the resources from the folder inputted?

As in no child folders included.

@Wolfrik_Creations “Resources.LoadAll” Loads all assets in a folder or file at path in a Resources folder. If path refers to a folder, all assets in the folder will be returned. This is because you have the same type in child’s folder. If you want to get only from “Spawns” folder then you have to remove the “Structure” folder from it.
For Example If you have 4 Sprites in “Spawns” folder and 2 Sprites in “Structure” folder then

Sprite [] spt = Resources.LoadAll<Sprite>("Sprites") ;

spt.Length will be 6.

If you have 4 Sprites in “Spawns” folder and 2 other type like Textures in “Structure” folder then

Sprite [] spt = Resources.LoadAll<Sprite>("Sprites") ;

spt.Length will be 4.

I hope you got it.

Unity Documentation, as usual is abysmal.

Resources.LoadAll will load all resources present in a Resources folder as long as the passed argument “path” matches the start of the path of a given resource file. You must think about “path” as a prefix filter.

That’s why when calling Resources.LoadAll(“MyFolder”) you’ll get any file whose path starts with MyFolder, as for example:
Resources/MyFolder/first.txt
Resources/MyFolder/second.txt
Resources/MyFolder/AnotherFolder/third.txt
Resources/MyFolder/AnotherFolder/AnotherFolder/fourth.txt

That’s also why when calling Resources.LoadAll(“”) you end up with all files under any Resources folder, because all files paths will match an empty prefix.