void SetSupplies() { foreach (CSUI_BuildingIcon ic in m_Icons) { DestroyImmediate(ic.gameObject); } m_Icons.Clear(); int storageCnt = 0, bedCnt = 0; CSUI_BuildingIcon storageBI = null, bedBI = null; foreach (CSElectric cse in m_PPCoal.m_Electrics) { if (cse.m_Type == CSConst.etStorage) { if (storageCnt == 0) { storageBI = _createIcons(cse); } storageCnt++; } else if (cse.m_Type == CSConst.etDwelling) { if (bedCnt == 0) { bedBI = _createIcons(cse); } bedCnt++; } else { _createIcons(cse); } } m_Supply.m_Root.repositionNow = true; if (storageBI != null) { storageBI.Description += " X " + storageCnt.ToString(); } if (bedBI != null) { bedBI.Description += " X " + bedBI.ToString(); } }
CSUI_BuildingIcon _createIcons(CSElectric cse) { CSUI_BuildingIcon bi = Instantiate(m_Supply.m_IconPrefab) as CSUI_BuildingIcon; bi.transform.parent = m_Supply.m_Root.transform; bi.transform.localPosition = Vector3.zero; bi.transform.localRotation = Quaternion.identity; bi.transform.localScale = Vector3.one; string[] iconStr = ItemProto.GetIconName(cse.ItemID); if (iconStr.Length != 0) { bi.IconName = iconStr[0]; } else { bi.IconName = ""; } bi.Description = cse.Name; m_Icons.Add(bi); return(bi); }