- Home /
Inconsistent Results with Resources.LoadAll
I have some prefabs in the Resources folder. All of them have a Monobehaviour component called TrophyData.
I call:
TrophyData[] trophies = Resources.FindObjectsOfTypeAll<TrophyData>();
I expect a fixed-length array of five objects of type TrophyData (as there are five prefabs).
But the length of "trophies" is inconsistent. There are five prefabs in the folder. Sometimes I get zero. Sometimes I get two. Sometimes I get all five. And nothing in the folder has changed.
Restarting the editor does not seem to have an effect, and I can think of nothing else that might affect the issue.
I'm on 5.4.0p2.
What am I doing wrong?
I'm curious what your usage/need is. If they're all in a folder, you should be able to just Resources.LoadAll from the folder into a list and be done with it.
I'm not sure of the behavior of FindObjectsOfType but it seems $$anonymous$$imally useful in this situation.
Your answer
Follow this Question
Related Questions
How to get the number of subfolders within a subfolder within resources? 0 Answers
Resource.LoadAll Not Working On Child Assets In Stand Alone Build 0 Answers
Unity3d Resources.LoadAll empty array 1 Answer
Resources.LoadAll on Current Folder Only? 1 Answer
Load a list of scripts from folder 1 Answer