system
April 17, 2012, 8:50am
1
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*.name);*
}
It shows
6
Pref1
Pref1
Pref2
Pref2
Pref3
Pref4
PS: Sorry for my English.
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 !