private void CreateUnit(int index) { units = god.GetUnits(); if (units.Count > 0) { for (int i = 0; i < units.Count; i++) { Building building = units[i].gameObject.GetComponent <Building>(); if (building != null) { building.CreateUnit(index); } } } }