public void CloseSelectBattleCharactersPanel() { List <PawnInstance> selected = new List <PawnInstance>(); if (transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersSelected).GetChild(0).childCount > 0) { selected.Add(transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersSelected).GetComponentInChildren <UIKeeperInstance>().keeperInstance); } if (transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersSelected).GetChild(1).childCount > 0) { selected.Add(transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersSelected).GetChild(1).GetComponentInChildren <UIKeeperInstance>().keeperInstance); } if (!isPrisonerOnTile) { if (transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersSelected).GetChild(2).childCount > 0) { selected.Add(transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersSelected).GetChild(2).GetComponentInChildren <UIKeeperInstance>().keeperInstance); } } BattleHandler.isPrisonerOnTile = isPrisonerOnTile; if (selected.Count == 0) { Debug.Log("At least one keeper must be selected"); return; } gameObject.SetActive(false); BattleHandler.LaunchBattle(activeTile, selected); activeTile = null; for (int i = 0; i < transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersSelected).childCount; i++) { if (transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersSelected).GetChild(i).childCount > 0) { Destroy(transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersSelected).GetChild(i).GetChild(0).gameObject); } } for (int i = 0; i < transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersOnTile).childCount; i++) { if (transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersOnTile).GetChild(i).childCount > 0) { Destroy(transform.GetChild((int)SelectBattleCharactersScreenChildren.CharactersOnTile).GetChild(i).GetChild(0).gameObject); } } }