Few words of friendly comments:
void Update () { // *** - ToString allocates at least 2 bytes for every character // **** - adding strings together with '+' operator is more or less equivalet to *** ItemContainer container = SingletonMB<StationContent>.Instance.GetContainer(); TextMeshProUGUI title = this.title;// this does nothing - remove line float num = container.CapacityUsed; string str1 = num.ToString("0");// *** num = container.Capacity;// reusing local variables is not needed for anything string str2 = num.ToString("0");// *** string str3 = "Items " + str1 + " / " + str2;// **** title.text = str3; this.sectionLines.RemoveAllLines(); foreach( ItemStack itemStack in container.Items )// unfortunately, starting 'foreach' allocates memory - in Update methods try to use simpler old 'for' iterator instead of 'foreach' { PanelSectionLines sectionLines = this.sectionLines;// this does nothing - remove line ItemType type = itemStack.Type; string _identifier = type.ToString();// *** type = itemStack.Type;// this does nothing - remove line string _text = type.ToString() + " " + itemStack.Amount.ToString("##");// **** sectionLines.Set(_identifier, _text); } }
Downsides of ToString() calls are not that simple to get rid of in context of UI. But it's better that you're aware of it and step-by-step will be trying to avoid them in the future (strings in general).