Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Formatting text

Discussion in 'UGUI & TextMesh Pro' started by Deleted User, Aug 27, 2014.

  1. Deleted User

    Deleted User

    Guest

    I was trying to implement my localization system with the new UI and I'm hitting a problem, probably I'm missing something. At runtime I parse a simple text files that is made of multiple lines, example:

    str000 = string 0
    str001 = string 1

    So I split each line by = and populate a dictionary with the left hand as key and right as value. It works all ok until I'm trying to add a carriage return (\n). Sadly I can't split one text in multiple lines, so to return I need to do all in one line, there is an alternative to using \n?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,777
    I'm not quite sure I'm grasping your problem, but is the issue that you need to double-escape? Use \\n in your code so that it shows up as \n in the text file?
     
  3. Deleted User

    Deleted User

    Guest

    I'm trying to avoid to show \n in the text. When I add it it doesn't return on a new line but it just include \n as text.
     
  4. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    This looks like .ini file - why not use free tool from google or other for parse them instead of reinventig wheel?

    If you see nothing support multiline then consider other format like .json .yaml etc.

    If u still need own way use regex with split and lazy quantifier (?) Like *? I had similar problem but for finding multiple links in text. Ah and use regexoption.singleline to ensure that ' .' (Dot alone) Symbol will work with multiline text

    I hope i was a bit helpful ;)
     
  5. Deleted User

    Deleted User

    Guest

    I just feel confortable that way. I can definetly do more splitting, but the fact is that another guy is passing strings with \n on text and for him it oes on newline, so thats why I was puzzled that doesn't happen for me.