public void SetProductionInfo(ProductionBuilding _pb) { m_Title.text = _pb.m_UIName; m_OperatingCost.text = UIManager.ConvertFloatToStringPriceWithSign(_pb.m_OperatingCost, out Color c); m_OperatingCost.color = c; foreach (Transform child in m_InputTransform.transform) { Destroy(child.gameObject); } foreach (Transform child in m_OutputTransform.transform) { Destroy(child.gameObject); } Production p = _pb.m_Production; if (p.m_Input.Count == 0) { GameObject obj = Instantiate(m_ProductionInfoItem_Prefab, m_InputTransform); ProductionInfoItem pii = obj.GetComponent <ProductionInfoItem>(); pii.SetAmount("∞"); } else { foreach (ProductionStat ps in p.m_Input) { GameObject obj = Instantiate(m_ProductionInfoItem_Prefab, m_InputTransform); ProductionInfoItem pii = obj.GetComponent <ProductionInfoItem>(); pii.SetAmount(ps.m_Amount); pii.SetIcon(ps.m_Product.m_UI_Sprit); } } if (p.m_Output.Count == 0) { GameObject obj = Instantiate(m_ProductionInfoItem_Prefab, m_InputTransform); ProductionInfoItem pii = obj.GetComponent <ProductionInfoItem>(); pii.SetAmount("∞"); } else { foreach (ProductionStat ps in p.m_Output) { GameObject obj = Instantiate(m_ProductionInfoItem_Prefab, m_OutputTransform); ProductionInfoItem pii = obj.GetComponent <ProductionInfoItem>(); pii.SetAmount(ps.m_Amount); pii.SetIcon(ps.m_Product.m_UI_Sprit); } } m_RatioText.text = (_pb.m_Production.m_Ratio * 100) + " %"; }
public void Init(ProductionBuilding _pb) { m_PB = _pb; m_Title.text = m_PB.m_UIName; m_Cost.text = UIManager.ConvertFloatToStringPrice(_pb.m_Cost); m_Balance.text = UIManager.ConvertFloatToStringPriceWithSign(_pb.m_OperatingCost, out Color c); m_Balance.color = c; m_Btn.interactable = false; m_UnlockBG.color = Color.red; m_Conditions = _pb.m_Production.m_Conditions; foreach (ProductionStat ps in m_PB.m_Production.m_Output) { GameObject obj = Instantiate(Output_Prefab, transform); obj.transform.SetSiblingIndex(1); m_Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, m_Rect.rect.height + 50f); TextMeshProUGUI t = null; foreach (Transform child in obj.transform) { if (child.gameObject.tag == "EditText") { t = child.GetComponent <TextMeshProUGUI>(); break; } } if (t == null) { Debug.LogError("No EditText Tag found in: " + obj); return; } t.text = ps.m_Amount.ToString() + " " + ps.m_Product.m_UI_Name; if (ps.m_Product.m_UI_Sprit != null) { Image i = obj.GetComponentInChildren <Image>(); i.sprite = ps.m_Product.m_UI_Sprit; } } foreach (ProductionStat ps in m_PB.m_Production.m_Input) { GameObject obj = Instantiate(Input_Prefab, transform); obj.transform.SetSiblingIndex(1); m_Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, m_Rect.rect.height + 50f); TextMeshProUGUI t = null; foreach (Transform child in obj.transform) { if (child.gameObject.tag == "EditText") { t = child.GetComponent <TextMeshProUGUI>(); break; } } if (t == null) { Debug.LogError("No EditText Tag found in: " + obj); return; } t.text = ps.m_Amount.ToString() + " " + ps.m_Product.m_UI_Name; if (ps.m_Product.m_UI_Sprit != null) { Image i = obj.GetComponentInChildren <Image>(); i.sprite = ps.m_Product.m_UI_Sprit; } } }