Search Unity

Windows paths reading as escape sequences

Discussion in 'Scripting' started by amasinton, Aug 19, 2009.

  1. amasinton

    amasinton

    Joined:
    Aug 12, 2006
    Posts:
    138
    I have a project which I started developing on os x and then recently got a Windows version of Unity Indie at work. So I just copied my project over to my Windows machine.

    I have a number of scripts which have file paths as variables. But when I changed them using the MS path convention of \ rather than the / on OS X, the slashes are being read as escape sequences.

    What is the trick to paths on Windows?

    If I had a file I needed to reference on my desktop on os x I'd just write /Users/anthony/Desktop/test.jpg

    But on Windows the equivalent is:
    C:\Documents and Settings\anthony\Desktop\test.jpg

    But of course Unity now thinks the '\D' in the Windows path is some sort of escape sequence (which it obviously isn't).

    What do I need to do different in Unity for Windows (using XP, BTW)?

    Thanks very much!
    -- Anthony
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you need to escape the \ that means, you replace / with \\

    alternative just use / as any NT deriavate windows, which means any windows aside of me / 98, is able to use / just as good as \
     
  3. amasinton

    amasinton

    Joined:
    Aug 12, 2006
    Posts:
    138
    Thanks for the advice. I converted all of the \ to / as you suggested and it's working fine now.

    It's the little differences like this that sneak up on me.

    Thanks again.
    -- Anthony