I wrote this small function which iterates over each child objects and checks whether it has an active tag. I would like to return the object that has an active tag, however, it returns the following error:
Assets/Game_Manager.cs(135,23): error CS0161: 'Game_Manager.getActive()': not all code paths return a value
Any idea on whats going on wrong here ?
public GameObject getActive()
{
//return GameObject.FindGameObjectsWithTag("Active")[0];
foreach (Transform child in parent.transform)
{
if (child.tag == "Active")
{
return child.gameObject;
}
}
}