private IEnumerator LoadStaticAssets() { if (!LoadedStatic) { LoadedStatic = false; List <KeyValuePair <string, Run> > actions = new List <KeyValuePair <string, Run> >(); actions.Add(new KeyValuePair <string, Run>("Loading Items...", () => { Item.LoadAll(); })); actions.Add(new KeyValuePair <string, Run>("Loading Projectiles...", () => { ProjectileData.LoadAll(); })); actions.Add(new KeyValuePair <string, Run>("Loading Effects...", () => { TempEffect.LoadAll(); })); actions.Add(new KeyValuePair <string, Run>("Loading Tiles...", () => { TileData.LoadAll(); })); actions.Add(new KeyValuePair <string, Run>("Registering Items...", () => { Item.NetRegisterAll(); })); int total = actions.Count; System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); // Loop and execute... for (int i = 0; i < total; i++) { var pair = actions[i]; // Execute... UI.Title = pair.Key; UI.Percentage = i / total; yield return(null); watch.Restart(); try { pair.Value.Invoke(); } catch (Exception e) { Debug.LogError("Exception when loading on step #{0} - '{1}':\n{2}".Form(i, pair.Key, e)); } watch.Stop(); Debug.Log("'{0}' - Took {1} milliseconds.".Form(pair.Key, watch.ElapsedMilliseconds)); } LoadedStatic = true; StartCoroutine(LoadScene()); } }