public void CreateOption(int index) { var uiChooseTile = UIManager.Singleton.UIChoosingTile; HexTile hexTile = null; if (index == 0) { hexTile = HexUtils.BuildHexTile(_hexTile.Data, Player.MyPlayer, HexTileRole.InUI); } else { var affordAble = false; var counter = 0; HexTileData randomData = null; while (!affordAble) { randomData = HexUtils.CreateRandomData(_hexTile.Data.X, _hexTile.Data.Y); counter++; if (counter == 100) { randomData = _hexTile.Data; UnityEngine.Debug.LogWarning("Could not find Random Data"); } affordAble = Player.MyPlayer.HasResource(HexUtils.CalcHexPrice(randomData)); } hexTile = HexUtils.BuildHexTile(randomData, Player.MyPlayer, HexTileRole.InUI); } hexTile.transform.SetParent(uiChooseTile.ChoosingTransforms[index].transform, false); hexTile.OnClickCallback = OnTileChosen; }