Search Unity

Question Vertical Text

Discussion in 'UGUI & TextMesh Pro' started by RamType0, May 15, 2020.

  1. RamType0

    RamType0

    Joined:
    Sep 11, 2018
    Posts:
    67
    How to place each characters of text vertically?
    I saw that it is done by setting width to 0.
    But this solution breaks preferred width and height,and auto size.
     
  2. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    How about that?

    Code (CSharp):
    1. string txt = "Hello World";
    2. txt = string.Join("\n", txt.ToCharArray());
    3. Debug.Log(txt);
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What is your expectation in terms of the preferred width being when the text is all vertical?

    Does PreferredWidth become the width of the widest characters?

    Then does PreferredHeight become sort of what normal horizontal layout preferredwidth would have been?

    Vertical Text Layout is certainly possible but having this work with Auto-size and preferred values is a different story.
     
  4. RamType0

    RamType0

    Joined:
    Sep 11, 2018
    Posts:
    67
    Yeah,PreferredWidth is set to widest character's width,and PreferredHeight is set to sum of these characters and padding.