- Home /
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.
Answer by saud_ahmed020 · Jun 10, 2016 at 06:18 AM
@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.
Alright, thank you.
I guess I will move the structures folder and re-code the scripts referring to that folder to the new one.
And sorry for the late reply.
Your answer
Follow this Question
Related Questions
Unity is hiding a Folder from me, but also tells me that in that Folder is a DLL missing. Wut ? 0 Answers
Load a list of scripts from folder 1 Answer
Correct Folder for Resources.Load() ? 1 Answer
How to prevent resources being unloaded unintentionally 0 Answers
Picture loaded from resource corrupted. 0 Answers