I want create a function that take any array of game Objects and return a random game object. I wrote these:
public GameObject[] items;
items = Resources.LoadAll<GameObject>("Game_Items") as GameObject[];
public GameObject getRandomItem()
{
int randomIndex = Random.Range(0, items.Length);
return items[randomIndex];
}
It works, but only for one array: Items. I want to know how can I modify this function that getRandomItem() takes any array, and return a random item from that array?