Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Calculating height of Text?

Discussion in 'UGUI & TextMesh Pro' started by ChimeraSW, Sep 19, 2014.

  1. ChimeraSW

    ChimeraSW

    Joined:
    Jul 24, 2013
    Posts:
    28
    Is it possible to get the final height of a Text component, post wrap? In other words, if I have a Text component, set with vertical overflow to Overflow, and enough text that it goes beyond the RectTransform's height, can I get the actual text height of the total overflowed text?
     
  2. JAKJ

    JAKJ

    Joined:
    Aug 17, 2014
    Posts:
    185
    Use the preferredHeight/preferredWidth properties of the Text, which is always the widest/tallest the text can be (ignoring its current RectTransform) with its current wrap/truncate/overflow settings.
     
    hotchick and ChimeraSW like this.
  3. ChimeraSW

    ChimeraSW

    Joined:
    Jul 24, 2013
    Posts:
    28
    Perfect, thanks!