So, I’ve got a textbox (TextMeshPro) with a load of text in it. As the game progresses, I add more text to the textbox and I want the user to see the bottom of the text (the last bit added)…

/// <summary>
/// Add text to the panel at the bottom of the screen
/// </summary>
public void AddTextToBottomPanel(string a_text)
{
  m_bottomPanelText.text += a_text;
  StartCoroutine(PushToBottom());
}

IEnumerator PushToBottom()
{
  yield return new WaitForEndOfFrame();
  m_bottomScrollRect.verticalNormalizedPosition = 0;
  LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)m_bottomScrollRect.transform);
}
Advertisements