public int SetItems(int currentState, int setNumber = -1) { activeTiles.Clear(); int tilesCount = 0; int firstIndex = -1; // Dictionary<int, int> loadedItem = GetLoadedItems(currentState); for (int i = 0; i < Inventory.GetItemCount(currentState); i++) { Item item = Inventory.GetItem(currentState, i); if (tilesCount < transform.childCount) { // Debug.Log("item.Name:" + item.name); // Debug.Log("item.Index: " + item.Index); currentTile = transform.GetChild(tilesCount).GetComponent <TileHandler>(); currentTile.currentState = item.currentState; currentTile.SetTile(item.image, item.name, item.Index); currentTile.Highlight = currentTile.GetNormal(); activeTiles.Add(item.Index, currentTile); transform.GetChild(tilesCount).gameObject.SetActive(true); tilesCount++; if (firstIndex.Equals(-1)) { firstIndex = item.Index; } } } for (int i = tilesCount; i < transform.childCount; i++) { transform.GetChild(i).gameObject.SetActive(false); } return(firstIndex); }