Search Unity

Formatting a ToString("#.# ... Character alignment

Discussion in 'Scripting' started by Thimble2600, Nov 30, 2015.

  1. Thimble2600

    Thimble2600

    Joined:
    Nov 27, 2015
    Posts:
    165
    Hello there, I'm making an XML editor script for saving and loading maps in a game.

    When I write GameObject's positions like so:

    Code (csharp):
    1. m_childTransforms[i].position.ToString("+000")
    I get results like this:

    Level Details:
    Element 0: (000, 000, 000)
    Element 1: (006, -078, 000)
    Element 2: (012, -078, 000)
    ...

    Can any tell me how I can keep these values in line with one another for easy reading?

    Seems negative values knock it out of line. I was thinking perhaps if it always showed positive and negative instead of only negative?

    If this can't be done then that's alright, I did my best, lesson learned :)
     
  2. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778