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?
@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
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.