Hello friend welcome . my code is as below
public GameObject[] Itemgroup1;
public List Itemgroup1list;
public GameObject Getitemgroup1() //function to be called
{
for (int i=0; i<Itemgroup1list.Count; i++) {
if(!Itemgroup1list*.activeInHierarchy)*
{
return Itemgroup1list*;*
}
}
this is my code that have a array of game object called “GameObject[] Itemgroup1” and each game object in that array is added to the list called “List Itemgroup1list” by some code that i didnt provided … so what i posted here is a function that is being called in game which returns a gameobject from the list which is currently inactive in heirarchy . So here is my problem while returning the inactive gameobject my function checks for an inactive game object in the list from top to bottom and returns the first gameobject that is found inactive and because of my game optimaizations there will only be 4 gameobjects active at anytime. so if my list contains 5 or more than 5 game objects , then only first 4 get active and in rare case the 5 th one also But the problem is that the remaining gameobjects in the list remains unactive whole the time . So what could i do so that that while returning any gameobject form my list my function returns a random inactive gameobject not the first inactive gameobject .
Hope the explanation of my problem was efficient…