This part of code is just my prototyping/lazy programming left for later :D I've wanted to base it on event instead of leaving it in update, but forgot about it when preparing actual event :/
Adding your suggestions (with exception for foreach, just for readability sake) and moving it to be based on event it now looks and perform a lot better :)
void Start() { sectionLines = GetComponent<PanelSectionLines>(); title = transform.Find("Title").GetComponentInChildren<TextMeshProUGUI>(); StationContent.Instance.OnContentChanged += HandleStationContentChanged; } private void HandleStationContentChanged(StationContent _stationContent) { ItemContainer container = _stationContent.GetContainer(); title.text = string.Format("Items {0:0} / {1:0}", container.CapacityUsed, container.Capacity); sectionLines.RemoveAllLines(); foreach (ItemStack stack in container.Items) { sectionLines.Set(Lang.ITEM_TYPE[stack.Type], string.Format("{0} {1:##}", Lang.ITEM_TYPE[stack.Type], stack.Amount)); } }