private IEnumerator RelayoutProc(bool reserveScrollValue, bool activateLast) { yield return(new WaitForEndOfFrame()); float height = MyCodeLine.Y_OFFSET * 2.0f; // Heads. headNumberWidth = 0.0f; foreach (MyCodeHead h in heads) { height += h.Rect().GetSize().y; if (h.TightWidth > headNumberWidth) { headNumberWidth = h.TightWidth; } } scrollHeadCol.Rect().offsetMin = new Vector2(0.0f, scrollHeadCol.Rect().offsetMin.y); scrollHeadCol.Rect().SetSize(new Vector2(headNumberWidth + MyCodeHead.X_OFFSET * 2.0f, scrollHeadCol.Rect().GetSize().y)); transHeadRoot.SetSize(new Vector2(headNumberWidth + MyCodeHead.X_OFFSET * 2.0f, height)); transHeadRoot.SetLeftPosition(0.0f); foreach (MyCodeHead h in heads) { h.Width = headNumberWidth; h.Relayout(); } yield return(new WaitForEndOfFrame()); // Lines. Vector2 locPos = transLineRoot.localPosition; float oldVal = scrollLineCol.verticalScrollbar.value; scrollLineCol.Rect().offsetMin = new Vector2(scrollHeadCol.Rect().GetSize().x, scrollLineCol.Rect().offsetMin.y); scrollLineCol.Rect().SetSize(new Vector2(this.Rect().GetSize().x - scrollHeadCol.Rect().GetSize().x, scrollLineCol.Rect().GetSize().y)); lineTextWidth = scrollLineCol.Rect().GetSize().x - 5; foreach (MyCodeLine l in lines) { if (l.TightWidth > lineTextWidth) { lineTextWidth = l.TightWidth; } } transLineRoot.SetSize(new Vector2(lineTextWidth + MyCodeLine.X_OFFSET * 2.0f, height)); transLineRoot.SetLeftPosition(scrollLineCol.verticalScrollbar.Rect().GetSize().x / 2.0f); yield return(new WaitForEndOfFrame()); foreach (MyCodeLine l in lines) { l.Width = lineTextWidth; l.Relayout(); } yield return(new WaitForEndOfFrame()); transLineRoot.localPosition = locPos; if (reserveScrollValue) { scrollLineCol.verticalScrollbar.value = 1.0f; yield return(new WaitForEndOfFrame()); scrollLineCol.verticalScrollbar.value = oldVal; } else { transLineRoot.localPosition = locPos; } // Activates last? if (activateLast) { EditLine(lines.Last()); } }