So I’m making something for my game, i set-up items in an array called “Questboxitems” I really need to find certain things in the array by name, as they’re loaded into this array at random.
One way of doing it would be to set up a custom function that handles this kind of thing, i.e.
GameObject GetQuestBoxItem (GameObject[] g, string name)
{
for (int i = 0; i < g.Length; i++)
{
if (g*.name == name)*
return g*;* }
Debug.Log (“No item has the name '” + name + “'.”); return null; } And then if you had to find that item, all you would do is go; GameObject item = GetQuestBoxItem (QuestBoxItems, “Text”);
if (item) item.GetComponent().enabled = true; else Debug.Log (“Could not find item.”);