I’m receiving a NullReferenceException from a foreach loop that is locating a series of sprites based on their tag. The loop is finding all of the present objects and incrementing the array appropriately. But it is only transferring the last of the found objects into the array. All the other sectors are being filled with null.
foreach(OTSprite go in temp){
if(go.gameObject.tag=="building"){
buildings=new OTSprite[i+1];
buildingOrigin=new Vector2[i+1];
buildings*=go;*
buildingOrigin_=buildings*.position;
buildings.position=beneathScreen;
i++;
}
}*_