Ok, so i have this code that is doing some really weird stuff.
if(_categoryIndexTemp != _categoryIndex)
{
_previewTextures = new List<Texture>();
Debug.Log("Prefabs Qty: " + filteredPrefabs.Length);
for (int j = 0; j < filteredPrefabs.Length; j++)
{
Texture text = null;
while (text == null)
{
text = AssetPreview.GetAssetPreview(filteredPrefabs[j]);
}
_previewTextures.Add(text);
Debug.Log(_previewTextures[0]);
}
Debug.Log("Textures Qty: " + _previewTextures.Count);
_categoryIndexTemp = _categoryIndex;
}
What is bassically doing is:
-When i change the category of my enum i need to take all the prefabs preview of a category that are already filtered in filteredPrefabs.
-Iām testing with some prefabs [137] and everything is loaded fine, 137 items none of them null.
-As you can see i go item by item getting the preview adn also look that i have a debug of the item number [0]
Why? That item is a UnityTexture2D and when the for reaches the item 50 item[0] turns to null and so on the other items [1] = null, [2]= null, and the last items of the List remain Texture2D.
Is there any chance the reference are being replaced?
The prefabs are the same but in different folders, i mean in a folder i have a cube and a sphere so i duplicate that folder x times.
Help! ![]()