- Home /
Problem with LoadAll, it duplicate the objects
I have a problem with Resources.LoadAll(), when I use it to load prefabs it loads twice the same prefab if it has something.
Example: My resources Folder: Pref1- With content Pref2- With content Pref3- Empty Pref4- Empty.
var xyz = Resources.LoadAll(_path);
Debug.Log(xyz..Length);
for(int i=0;i<xyz.Length;i++)
{
Debug.Log(xyz[i].name);
}
It shows 6 Pref1 Pref1 Pref2 Pref2 Pref3 Pref4
PS: Sorry for my English.
Answer by PommPoirAbricot · Jun 03, 2013 at 05:08 PM
Hi i had the same problem as you and i solve it this way:
m_objects = m_objects.GroupBy(p => p.name).Select(g => g.First()).ToList();
Here m_objects is a collection of UnityEngine.Object
Can be useful linq-distinct-on-a-particular-property remove-duplicates-from-a-listt-in-c-sharp Hope that's help someone
PS: If anyone can explain or tell us how to avoid this problem about getting twice a reference on some assets extracted from a bundle, it will be greatly appreciated !
Your answer

Follow this Question
Related Questions
Skybox on/off Issues 1 Answer
Generic USB Controller axis issue 0 Answers
Launching game in windowed mode by default (problem) 6 Answers
Why is a Unity Demo not working on Macintosh? 1 Answer
multiplying door problem!! 2 Answers