public BattleUnit LoadUnit(Unit unit) { GameObject newUnit = Instantiate(unitPrefab, (unit.IsHero)? heroesContent : enemiesContent); int sortingLayer = 0; foreach (Transform child in ((unit.IsHero)? heroesContent : enemiesContent)) { sortingLayer++; sortingLayer++; } BattleUnit battleUnit = newUnit.GetComponentInChildren <BattleUnit>(); battleUnit.GetComponent <SpriteRenderer>().sortingOrder = sortingLayer; battleUnit.Configure(unit); Sprite unitSprite = battleUnit.GetComponent <SpriteRenderer>().sprite; AxisInteractableItem newItem = battleUnit.GetComponent <AxisInteractableItem>(); AIIManager manager = (unit.IsHero)? heroesManager : enemiesManager; battleUnit.battleItem = battleUnit.GetComponent <UnitItem>(); battleUnit.battleItem.layout.preferredWidth = unit.BoundsSizeX * 64; battleUnit.battleItem.layout.preferredHeight = unit.BoundsSizeY * 64; newUnit.transform.rotation = Quaternion.identity; Image[] unitImages = newUnit.GetComponentsInChildren <Image>(); unitImages[0].sprite = (unit.GetType() == typeof(Hero))? heroIndicator : enemyIndicator; unitImages[1].sprite = unitSprite; // Ordena o item na lista if (manager.lastItem != null) { newItem.upItem = manager.lastItem; manager.lastItem.downItem = newItem; } else { manager.firstItem = newItem; } manager.lastItem = newItem; return(battleUnit); }