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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

String text alignment

Discussion in 'Getting Started' started by heipp123, Oct 1, 2015.

  1. heipp123

    heipp123

    Joined:
    Aug 1, 2015
    Posts:
    8
    hi
    guys
    how do i alignment one to right and another to left side.

    Code (CSharp):
    1. highscoreFields[i].text += highscoreList[i].username + "  " + highscoreList[i].score;
    now its look like this

    but i want it like this



    thanks.
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,848
    You use two separate texts (one left-aligned, one right-aligned).
     
  3. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    They'd have to be two separate text objects for you to align them differently.

    Edit: Joe the ninja.
     
    JoeStrout likes this.
  4. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    556
    Two text objects is the way to go, imho. You could also use one field, set a maximum length, and then pad the middle with spaces....but that is a lot of work.
     
  5. heipp123

    heipp123

    Joined:
    Aug 1, 2015
    Posts:
    8
    thanks you all.