protected void UpdateVisibleText ()
{
if (isValid)
{
if (mTotalLines == 0)
{
textLabel.text = "";
return;
}
int maxLines = Mathf.FloorToInt((float)textLabel.height / lineHeight);
int sh = Mathf.Max(0, mTotalLines - maxLines);
int offset = Mathf.RoundToInt(mScroll * sh);
if (offset < 0) offset = 0;
StringBuilder final
= new StringBuilder
();
for (int i = mParagraphs.size; maxLines > 0 && i > 0; ) // <-- this right here
{
Paragraph p = mParagraphs.buffer[--i]; // <-- and this
for (int b = 0, bmax = p.lines.Length; maxLines > 0 && b < bmax; ++b)
{
string s = p.lines[b];
if (offset > 0)
{
--offset;
}
else
{
if (final.Length > 0) final.Append("\n");
final.Append(s);
--maxLines;
}
}
}
textLabel.text = final.ToString();
}
}