protected TableRow RenderDataRow(Dictionary <string, string> data) { var dataRow = Instantiate <TableRow>(templateDataRow, "Data Row"); table.AddRow(dataRow); // create the data cells foreach (var heading in headings) { var dataCell = Instantiate <TableCell>(templateDataCell, "Data Cell"); dataRow.AddCell(dataCell); var text = dataCell.GetComponentInChildren <Text>(); text.text = data.ContainsKey(heading) ? data[heading] : String.Empty; } dataRows.Add(dataRow); XmlLayoutTimer.AtEndOfFrame(() => { if (table != null) { table.CalculateLayoutInputHorizontal(); } }, this); return(dataRow); }
IEnumerator AddRowsUsingTemplate() { while (numberOfRowsAdded <= numberOfRowsToAdd) { // Create a new row based on our template var newRow = Instantiate <TableRow>(rowTemplate); // the template is inactive, so we need to make our new row active newRow.gameObject.SetActive(true); // add the new row to the table tableLayout.AddRow(newRow); // In order for the scrollview to work correctly, its content transform must have the same height as our table scrollviewContent.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (tableLayout.transform as RectTransform).rect.height); // set the text value in the first cell var textObject = newRow.Cells[0].GetComponentInChildren <Text>(); textObject.text = "Row " + numberOfRowsAdded; // set the value for the toggle element in the second cell (even rows on, odd rows off) var toggleObject = newRow.Cells[1].GetComponentInChildren <Toggle>(); toggleObject.isOn = numberOfRowsAdded % 2 == 0; // increment the number of rows added (so that the example doesn't continue forever) numberOfRowsAdded++; // wait briefly before adding the next row yield return(new WaitForSeconds(0.25f)); } }
public void CreateTariffTable() { App app = UnityEngine.Object.FindObjectOfType <App>(); Dictionary <int, Nation> nations = State.getNations(); for (int i = 0; i < nations.Count; i++) { var newRow = Instantiate <TableRow>(tarrifRow); //var fieldGameObject = new GameObject("Field", typeof(RectTransform)); newRow.gameObject.SetActive(true); newRow.preferredHeight = 30; var textGameObject = new GameObject("Text", typeof(RectTransform)); tariffTable.AddRow(newRow); scrollviewContent.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (tariffTable.transform as RectTransform).rect.height); List <TableCell> cells = newRow.Cells; Text nationName = cells[0].GetComponent <Text>(); nationName.text = nations[i].getNationName(); for (int j = 1; j < cells.Count; j++) { InputField tarrif = cells[j].GetComponent <InputField>(); tarrif.text = "0"; } } }
private TableLayout orderTableByColumValue(TableLayout table, int colNum, bool descending) { Debug.Log("Size of Original Table: " + tableLayout.Rows.Count); // TableLayout tempTable = CreateCopyTable(); TableLayout tempTable = Instantiate <TableLayout>(tableLayout); Debug.Log("Size of Temp Table: " + tempTable.Rows.Count); Dictionary <int, string> rowsToColValues = new Dictionary <int, string>(); for (int i = 0; i < table.Rows.Count; i++) { TableRow currentRow = table.Rows[i]; // string stringValue = currentRow.Cells[colNum].GetComponentInChildren<Text>().text; //float floatValue = float.Parse(stringValue, CultureInfo.InvariantCulture.NumberFormat); // int intValue = (int)Math.Floor(floatValue); rowsToColValues[i] = currentRow.Cells[colNum].GetComponentInChildren <Text>().text; } var ordered = rowsToColValues.OrderBy(x => x.Value); if (descending) { ordered = rowsToColValues.OrderByDescending(x => x.Value); } Dictionary <int, int> rowMapper = new Dictionary <int, int>(); int index = 0; foreach (var item in ordered) { rowMapper[index] = item.Key; Debug.Log(index + " " + rowMapper[index]); index++; } table.ClearRows(); for (int i = 0; i < tempTable.Rows.Count; i++) { TableLayout tempTable2 = Instantiate <TableLayout>(tempTable); // Debug.Log("Count of Temp: " + tempTable.Rows.Count); int ind = rowMapper[i]; Debug.Log(rowMapper[i]); TableRow thisRow = tempTable2.Rows[ind]; // tempTable.Rows[10] = tempTable2.Rows[10]; table.AddRow(thisRow); // TableRow newRow = Instantiate<TableRow>(tempTable.Rows[rowMapper[i]]); // table.AddRow(newRow); Destroy(tempTable2); } // Destroy(tempTable); Debug.Log("Right Before Update"); // table.UpdateLayout(); Destroy(tempTable); tempTable.transform.localScale.Set(0f, 0f, 0f); return(table); }
private void CreateNationList() { App app = UnityEngine.Object.FindObjectOfType <App>(); int playerIndex = app.GetHumanIndex(); Nation player = State.getNations()[playerIndex]; nationList.ClearRows(); foreach (Nation nation in State.getNations().Values) { Debug.Log(nation.getType()); if (nation.getType() == MyEnum.NationType.oldMinor || nation.getIndex() == player.getIndex()) { continue; } TableRow newRow = Instantiate <TableRow>(nationRow); newRow.gameObject.SetActive(true); newRow.preferredHeight = 30; newRow.name = nation.getIndex().ToString(); Debug.Log("Row Name:" + newRow.name); nationList.AddRow(newRow); scrollviewContent.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (nationList.transform as RectTransform).rect.height); Transform res = newRow.Cells[0].transform.GetChild(0); Image resImg = res.GetComponent <Image>(); resImg.preserveAspect = true; resImg.sprite = Resources.Load("Flags/" + nation.getNationName().ToString(), typeof(Sprite)) as Sprite; //newRow.Cells[0].GetComponentInChildren<Image>().sprite = Resources.Load("Resource/" + resource.ToString(), typeof(Sprite)) as Sprite; newRow.Cells[1].GetComponentInChildren <Text>().text = nation.getNationName().ToString(); if (nation.getType() == MyEnum.NationType.major) { } if (nation.getType() == MyEnum.NationType.minor) { } if (nation.getType() == MyEnum.NationType.oldEmpire) { } } scrollviewContent.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (nationList.transform as RectTransform).rect.height); }
private void CreateTable() { Debug.Log("Making Province Table..."); App app = UnityEngine.Object.FindObjectOfType <App>(); int playerIndex = app.GetHumanIndex(); Nation player = State.getNations()[playerIndex]; Market market = State.market; provinceTable.ClearRows(); int turn = State.turn; Debug.Log("Num provinces: " + player.getProvinces().Count); foreach (int provIndex in player.getProvinces()) { Province prov = State.getProvinces()[provIndex]; TableRow newRow = Instantiate <TableRow>(provRow); newRow.gameObject.SetActive(true); newRow.preferredHeight = 25; newRow.name = prov.getProvName(); Debug.Log(prov.getProvName()); provinceTable.AddRow(newRow); provConnector.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (provinceTable.transform as RectTransform).rect.height); // Transform res = newRow.Cells[0].transform.GetChild(0); newRow.Cells[0].GetComponentInChildren <Text>().text = prov.getProvName(); Transform res = newRow.Cells[1].transform; Image resImg = res.GetComponent <Image>(); resImg.preserveAspect = true; resImg.sprite = Resources.Load("Resource/" + prov.getResource().ToString(), typeof(Sprite)) as Sprite; newRow.Cells[2].GetComponentInChildren <Text>().text = prov.getDevelopmentLevel().ToString(); // newRow.Cells[3].GetComponentInChildren<Text>().text = prov.getInfrastructure().ToString(); newRow.Cells[4].GetComponentInChildren <Text>().text = prov.getProduction().ToString("0.0"); // newRow.Cells[5].GetComponentInChildren<Text>().text = prov.getPOP().ToString(); newRow.Cells[6].GetComponentInChildren <Text>().text = prov.getFortLevel().ToString(); newRow.Cells[7].GetComponentInChildren <Text>().text = prov.getCulture().ToString(); } provConnector.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (provinceTable.transform as RectTransform).rect.height); }
void CreateTable() { App app = UnityEngine.Object.FindObjectOfType <App>(); int playerIndex = app.GetHumanIndex(); Debug.Log(playerIndex); Nation player = State.getNations()[playerIndex]; Market market = State.market; tableLayout.ClearRows(); int turn = State.turn; High.interactable = false; Medium.interactable = false; Low.interactable = false; plus.interactable = false; minus.interactable = false; foreach (MyEnum.Resources resource in Enum.GetValues(typeof(MyEnum.Resources))) { if (resource == MyEnum.Resources.gold) { continue; } if (resource == MyEnum.Resources.rubber && !player.GetTechnologies().Contains("electricity")) { continue; } if (resource == MyEnum.Resources.oil && !player.GetTechnologies().Contains("oil_drilling")) { continue; } TableRow newRow = Instantiate <TableRow>(testRow); // var fieldGameObject = new GameObject("Field", typeof(RectTransform)); newRow.gameObject.SetActive(true); newRow.preferredHeight = 30; newRow.name = resource.ToString(); tableLayout.AddRow(newRow); scrollviewContent.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (tableLayout.transform as RectTransform).rect.height); Transform res = newRow.Cells[0].transform.GetChild(0); Image resImg = res.GetComponent <Image>(); resImg.preserveAspect = true; resImg.sprite = Resources.Load("Resource/" + resource.ToString(), typeof(Sprite)) as Sprite; Text resText = newRow.Cells[0].GetComponentInChildren <Text>(); resText.text = resource.ToString(); //newRow.Cells[0].GetComponentInChildren<Image>().sprite = Resources.Load("Resource/" + resource.ToString(), typeof(Sprite)) as Sprite; newRow.Cells[1].GetComponentInChildren <Text>().text = player.getNumberResource(resource).ToString(); if (turn == 1) { newRow.Cells[2].GetComponentInChildren <Text>().text = "3"; } else { newRow.Cells[2].GetComponentInChildren <Text>().text = market.getPriceOfResource(resource).ToString(); } Transform chg = newRow.Cells[3].transform.GetChild(0); Image chgImg = chg.GetComponent <Image>(); Text chgText = newRow.Cells[3].GetComponentInChildren <Text>(); chgText.text = "flat"; chgImg.preserveAspect = true; if (turn < 2) { chgImg.sprite = Resources.Load("Sprites/flat", typeof(Sprite)) as Sprite; } else { float currentTurnPrice = market.getPriceOfResource(resource); float lastTurnPrice = market.getResourcePriceHistory(resource)[State.turn - 1]; if (currentTurnPrice > lastTurnPrice) { chgImg.sprite = Resources.Load("Sprites/greenUp", typeof(Sprite)) as Sprite; chgText.text = "up"; } else if (currentTurnPrice < lastTurnPrice) { chgImg.sprite = Resources.Load("Sprites/redDown", typeof(Sprite)) as Sprite; chgText.text = "down"; } } float producing = PlayerCalculator.getResourceProducing(player, resource); newRow.Cells[4].GetComponentInChildren <Text>().text = producing.ToString("F2"); } foreach (MyEnum.Goods good in Enum.GetValues(typeof(MyEnum.Goods))) { if (good == MyEnum.Goods.chemicals && !player.GetTechnologies().Contains("chemistry")) { continue; } if (good == MyEnum.Goods.gear && !player.GetTechnologies().Contains("electricity")) { continue; } if (good == MyEnum.Goods.telephone && !player.GetTechnologies().Contains("telephone")) { continue; } if (good == MyEnum.Goods.auto && !player.GetTechnologies().Contains("automobile")) { continue; } if (good == MyEnum.Goods.fighter && !player.GetTechnologies().Contains("flight")) { continue; } if (good == MyEnum.Goods.tank && !player.GetTechnologies().Contains("mobile_warfare")) { continue; } TableRow newRow = Instantiate <TableRow>(testRow); newRow.gameObject.SetActive(true); newRow.preferredHeight = 30; newRow.name = good.ToString(); tableLayout.AddRow(newRow); scrollviewContent.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (tableLayout.transform as RectTransform).rect.height); List <TableCell> cells = newRow.Cells; Transform res = newRow.Cells[0].transform.GetChild(0); Image resImg = res.GetComponent <Image>(); resImg.preserveAspect = true; resImg.sprite = Resources.Load("FinishedGoods/" + good.ToString(), typeof(Sprite)) as Sprite; newRow.Cells[1].GetComponentInChildren <Text>().text = player.getNumberGood(good).ToString(); if (turn == 1) { newRow.Cells[2].GetComponentInChildren <Text>().text = "5"; } else { newRow.Cells[2].GetComponentInChildren <Text>().text = market.getPriceOfGood(good).ToString(); } Transform chg = newRow.Cells[3].transform.GetChild(0); Image chgImg = chg.GetComponent <Image>(); chgImg.preserveAspect = true; if (turn < 2) { chgImg.sprite = Resources.Load("Sprites/flat", typeof(Sprite)) as Sprite; } else { float currentTurnPrice = market.getPriceOfGood(good); float lastTurnPrice = market.getGoodPriceHistory(good)[turn - 1]; if (currentTurnPrice > lastTurnPrice) { chgImg.sprite = Resources.Load("Sprites/greenUp", typeof(Sprite)) as Sprite; } else if (currentTurnPrice < lastTurnPrice) { chgImg.sprite = Resources.Load("Sprites/redDown", typeof(Sprite)) as Sprite; } } float producing = player.industry.getGoodProducing(good); newRow.Cells[4].GetComponentInChildren <Text>().text = producing.ToString(); } itemImage.sprite = Resources.Load("Resources/" + currentItem, typeof(Sprite)) as Sprite; if (State.turn > 1) { offeredLastTurn.text = "Offered Last Turn: " + market.getNumberOfResourcesOffered(MyEnum.Resources.wheat).ToString(); soldLastTurn.text = "Sold Last Turn: " + market.getNumberResourcesSold(MyEnum.Resources.wheat).ToString(); priceHistory = market.getResourcePriceHistory(MyEnum.Resources.wheat); } else { offeredLastTurn.text = "Offered Last Turn: 0"; soldLastTurn.text = "Sold Last Turn: 0"; } }
public void UpdateDisplay() { // don't do anything if we aren't actually active in the hierarchy // (basically, we're either inactive or a prefab) if (!this.gameObject.activeInHierarchy) { return; } if (Config.Sizing.OverrideTransformHeight) { Ref_DatePickerTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Config.Sizing.PreferredHeight); } UpdateBorder(); UpdateHeader(); UpdateWeekDayHeaders(); UpdateDaySection(); // Free all buttons in the pool buttonPool.FreeAll(); // Clear existing data Ref_DayTable.ClearRows(); // Day Names var dayNameRow = Ref_DayTable.AddRow(0); dayNameRow.dontUseTableRowBackground = true; // Empty cell if we're showing the Week Numbers column if (Config.WeekDays.ShowWeekNumbers) { var header = Instantiate(Ref_Template_DayName); dayNameRow.AddCell(header.Cell); Ref_DayTable.ColumnWidths[0] = Config.WeekDays.WeekNumberColumnWidth; } else { Ref_DayTable.ColumnWidths[0] = 0; } var dayNames = DatePickerUtilities.GetAbbreviatedDayNames(); foreach (var dayName in dayNames) { var header = Instantiate(Ref_Template_DayName); dayNameRow.AddCell(header.Cell); header.HeaderText.text = dayName; } // Validate our Date Range (if necessary. This method will output an error message if we fail) bool dateRangeValid = Config.DateRange.Validate(); // Dates var days = DatePickerUtilities.GetDateRangeForDisplay(VisibleDate.Date); TableRow row = null; int weekNumber = 1; DateTimeFormatInfo currentDateTimeFormatInfo = DateTimeFormatInfo.CurrentInfo; foreach (var day in days) { if (day.DayOfWeek == DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek) { row = Ref_DayTable.AddRow(0); if (Config.WeekDays.ShowWeekNumbers) { if (Config.WeekDays.WeekNumberMode == WeekNumberMode.WeekOfYear) { weekNumber = currentDateTimeFormatInfo.Calendar.GetWeekOfYear(day, Config.WeekDays.CalendarWeekRule, currentDateTimeFormatInfo.FirstDayOfWeek); } var weekNumberCell = Instantiate(Ref_Template_DayName); row.AddCell(weekNumberCell.Cell); weekNumberCell.HeaderText.text = weekNumber.ToString(); weekNumber++; } } if (!Config.Misc.ShowDatesInOtherMonths && !DatePickerUtilities.DateFallsWithinMonth(day, VisibleDate)) { // add an empty cell row.AddCell(); } else { var dayType = GetDayTypeForDate(day); var dayItem = buttonPool.GetButton(dayType); //var dayItem = Instantiate(GetDayTemplateForDate(day)); row.AddCell(dayItem.Cell); dayItem.Text.text = day.Day.ToString(); dayItem.DatePicker = this; dayItem.Date = day; dayItem.name = day.ToDateString(); dayItem.IsTemplate = false; dayItem.Button.interactable = true; if (dateRangeValid) // if the date range is not valid, then don't attempt to use it { if ((Config.DateRange.RestrictFromDate && day.CompareTo(Config.DateRange.FromDate) < 0) || (Config.DateRange.RestrictToDate && day.CompareTo(Config.DateRange.ToDate) > 0)) { dayItem.Button.interactable = false; } } } } if (Ref_InputField != null && Ref_InputFieldContainer != null && Ref_InputFieldToggleButtonCell != null) { Ref_InputField.text = SelectedDate.HasValue ? SelectedDate.Date.ToString(Config.Format.DateFormat) : ""; if (Ref_ScreenOverlay != null) { Ref_ScreenOverlay.color = Config.Modal.ScreenOverlayColor; } var valueBefore = Ref_InputFieldContainer.ColumnWidths.ToList(); if (Config.InputField.ShowToggleButton) { Ref_InputFieldContainer.ColumnWidths = new List <float> { 0, Config.InputField.ToggleButtonWidth }; Ref_InputFieldToggleButtonCell.gameObject.SetActive(true); } else { Ref_InputFieldContainer.ColumnWidths = new List <float> { 0 }; Ref_InputFieldToggleButtonCell.gameObject.SetActive(false); } if (!valueBefore.SequenceEqual(Ref_InputFieldContainer.ColumnWidths)) { Ref_InputFieldContainer.UpdateLayout(); } } }
private void updateAuctionPanel() { Debug.Log("Update Auction Panel ___________________________"); App app = UnityEngine.Object.FindObjectOfType <App>(); int playerIndex = app.GetHumanIndex(); Nation player = State.getNations()[playerIndex]; AuctionHandler auction = State.getAuctionHandler(); Nation item = State.getNations()[auction.getIndexOfCurrentItem()]; // Debug.Log(playerIndex); //TextMeshProUGUI currentPlayerBid = currentBidAmount.GetComponent<TextMeshProUGUI>(); currentBidAmount.text = auction.getPlayerBid(playerIndex).ToString(); if (auction.getPlayerBid(playerIndex) > 0 && !auction.getIfPlayerPass(playerIndex)) { decreaseBid.interactable = true; } else { decreaseBid.interactable = false; } if (player.ColonialPoints <= State.CurrentColonyAuctionBid || player.RecognizingTheseClaims.Contains(item.getIndex()) || auction.getIfPlayerPass(playerIndex) || player.landForces.Strength < 2) { increaseBid.interactable = false; } else { increaseBid.interactable = true; } biddingTable.ClearRows(); for (int i = 0; i < auction.getBiddingOrder().Count; i++) { int currNationIndex = auction.getBiddingOrder()[i]; Nation currNat = State.getNations()[currNationIndex]; TableRow newRow = Instantiate <TableRow>(biddingRow); newRow.gameObject.SetActive(true); newRow.preferredHeight = 30; newRow.name = currNat.getIndex().ToString(); biddingTable.AddRow(newRow); biddingConnector.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (biddingTable.transform as RectTransform).rect.height); int currNatIndex = currNat.getIndex(); // Debug.Log("Current Nation: " + currNatIndex); int currentNatBid = auction.getPlayerBid(currNatIndex); newRow.Cells[0].GetComponentInChildren <Text>().text = currentNatBid.ToString(); newRow.Cells[1].GetComponentInChildren <Text>().text = currNat.getNationName().ToString(); // Transform res = newRow.Cells[2].transform.GetChild(0); UIObject3D flagImage = newRow.Cells[2].GetComponentInChildren <UIObject3D>(); // flagImage.sprite = Resources.Load("Flags/" + currNat.getNationName().ToString(), typeof(Sprite)) as Sprite; GameObject flagPrefab = Instantiate(Resources.Load <GameObject>("Flags/Prefabs/" + currNat.getNationName())); flagImage.ObjectPrefab = flagPrefab.transform; flagImage.RenderScale = 0; flagImage.LightIntensity = 1; Transform statusTransform = newRow.Cells[3].transform.GetChild(0); Image statusImage = statusTransform.GetComponent <Image>(); if (auction.getIfPlayerPass(currNatIndex) == true) { statusImage.sprite = Resources.Load("Sprites/GUI/Dark_Red_x", typeof(Sprite)) as Sprite; } else { statusImage.sprite = Resources.Load("Sprites/GUI/AuctionHammer", typeof(Sprite)) as Sprite; } } if (auction.getPlayerBid(playerIndex) > State.CurrentColonyAuctionBid) { bid.interactable = true; } else { bid.interactable = false; } TextMeshProUGUI passButtonText = pass.GetComponentInChildren <TextMeshProUGUI>(); if (auction.getIfPlayerPass(playerIndex) || auction.getHighestBidderSoFar() == playerIndex) { passButtonText.SetText("Continue"); } else { passButtonText.SetText("Pass"); } }
private void showTradeResults(Nation player) { Debug.Log("Preparing Trade Results"); Market market = State.market; TradeResults.SetActive(true); tradeResultsEnter.Play(); float imports = player.getImportValues(); float exports = player.getExportValue(); imports = (float)Math.Round(imports, 2); exports = (float)Math.Round(exports, 2); float difference = Mathf.Abs(imports - exports); difference = (float)Math.Round(difference, 2); TextMeshProUGUI _importExportDif = importExportDif.GetComponent<TextMeshProUGUI>(); if (imports > exports) { _importExportDif.SetText("Imports: " + imports + " Exports: " + exports + " Deficit: " + difference); _importExportDif.color = new Color32(255, 0, 0, 255); } else { _importExportDif.SetText("Imports: " + imports + " Exports: " + exports + " Surplus: " + difference); _importExportDif.color = new Color32(0, 204, 0, 255); } ImportsResultTable.ClearRows(); foreach(Signal imp in player.getImports()) { TableRow newRow = Instantiate<TableRow>(resSoldRow); newRow.gameObject.SetActive(true); newRow.preferredHeight = 25; ImportsResultTable.AddRow(newRow); importsConnector.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (ImportsResultTable.transform as RectTransform).rect.height); newRow.Cells[0].GetComponentInChildren<Text>().text = "Bought"; //Image Transform res = newRow.Cells[1].transform.GetChild(0); Image resImg = res.GetComponent<Image>(); resImg.preserveAspect = true; if (imp.getRes()) { resImg.sprite = Resources.Load("Resource/" + imp.getResourceType().ToString(), typeof(Sprite)) as Sprite; } else { resImg.sprite = Resources.Load("FinishedGoods/" + imp.getGoodType().ToString(), typeof(Sprite)) as Sprite; } newRow.Cells[2].GetComponentInChildren<Text>().text = "from"; Transform flag = newRow.Cells[3].transform.GetChild(0); //Image flagImg = flag.GetComponent<Image>(); UIObject3D flagObject = flag.GetComponent<UIObject3D>(); // flagImg.preserveAspect = true; Nation owner = State.getNations()[imp.getOwnerIndex()]; GameObject flagPrefab = Instantiate(Resources.Load<GameObject>("Flags/Prefabs/" + owner.getNationName())); flagObject.ObjectPrefab = flagPrefab.transform; // flagImg.sprite = Resources.Load("Flags/" + owner.getName().ToString(), typeof(Sprite)) as Sprite; newRow.Cells[4].GetComponentInChildren<Text>().text = "for " + imp.getPriceSold().ToString("0.0"); } ExportsResultTable.ClearRows(); foreach (Signal exp in player.getExports()) { TableRow newRow = Instantiate<TableRow>(resSoldRow); newRow.gameObject.SetActive(true); newRow.preferredHeight = 25; ExportsResultTable.AddRow(newRow); exportConnector.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (ExportsResultTable.transform as RectTransform).rect.height); newRow.Cells[0].GetComponentInChildren<Text>().text = "Sold"; Transform res = newRow.Cells[1].transform.GetChild(0); Image resImg = res.GetComponent<Image>(); resImg.preserveAspect = true; if (exp.getRes()) { resImg.sprite = Resources.Load("Resource/" + exp.getResourceType().ToString(), typeof(Sprite)) as Sprite; } else { resImg.sprite = Resources.Load("FinishedGoods/" + exp.getGoodType().ToString(), typeof(Sprite)) as Sprite; } newRow.Cells[2].GetComponentInChildren<Text>().text = "to"; Transform flag = newRow.Cells[3].transform.GetChild(0); //Image flagImg = flag.GetComponent<Image>(); //flagImg.preserveAspect = true; Nation owner = State.getNations()[exp.getOwnerIndex()]; UIObject3D flagObject = flag.GetComponent<UIObject3D>(); Debug.Log(owner.getNationName()); GameObject flagPrefab = Instantiate(Resources.Load<GameObject>("Flags/Prefabs/" + owner.getNationName())); flagObject.ObjectPrefab = flagPrefab.transform; //flagImg.sprite = Resources.Load("Flags/" + owner.getName().ToString(), typeof(Sprite)) as Sprite; newRow.Cells[4].GetComponentInChildren<Text>().text = "for " + exp.getPriceSold().ToString("0.0"); } Debug.Log("Finished Preparing Trade Results"); // State.advanceGamePhase(); }