private IEnumerator HandleUpdateEvent(Unit lastUnit, Direction direction) { unit.DoneLoading = false; // TODO consider letting this be accessed by row controller if (direction == Direction.Null) { Clear(); unit.DoneLoading = true; yield break; } // get references to data var last = lastUnit.GetComponent <BookshelfController>(); if (last == null) { Debug.LogError("Could not get last shelf"); yield break; } var lastData = last.Data; if (lastData == null) { Debug.LogError("Last unit did not have data"); yield break; } // load data var done = false; Data = new Bookshelf(lastData.Start, lastData.End, ShelfCount, ShelfWidth); new Thread(o => { Data.Load(direction); done = true; }).Start(); // instantiate gameObjects while (!done) { yield return(null); } unit.DoneLoading = true; yield return(InstantiateTable()); unit.Row.NotifyScrollOk(); Display.text = Data.Start; }