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. Dismiss Notice

Does -projectPath support relative paths?

Discussion in 'Editor & General Support' started by GTaveira, Aug 9, 2013.

  1. GTaveira

    GTaveira

    Joined:
    May 20, 2009
    Posts:
    29
    Hi,

    I'm trying to use the command line arguments to create a batch file to automate the build process of our project.

    Since it is a complex system with several different Unity projects and there are several developers working on it, I was hoping to create a batch file that would use relative path instead of absolute path, as the latter would require each developer to customize the batch file by setting the -projectPath to his project's local path.

    From my tests it seems that -projectPath only takes absolute paths. I tried several variations of relative paths but it simply did not work.

    The documentation on this topic does not bring enough information.


    My question is: does the argument -projectPath support relative paths?


    EDIT: I'm using Unity 4.1.2f1 and Windows 7 SP1
     
    Last edited: Aug 9, 2013
  2. GTaveira

    GTaveira

    Joined:
    May 20, 2009
    Posts:
    29
    Does anyone have any insight on this possible limitation? I just wish to know if it is possible to pass a relative path to the -projectPath argument.

    Thanks in advance for the attention!
     
  3. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Where is your batch file located? There are a couple of things you can do... but let's say you force your devs to use a standard convention:


    <drive>:\<path>\<otherpath>\YourGamePath

    If you put your batch file inside <otherpath> and force it to be there... then you can use:
    %cd%\YourGamePath


    %cd% is a pseudo-variable in the batch file that gets the current directory.
     
  4. GTaveira

    GTaveira

    Joined:
    May 20, 2009
    Posts:
    29
    Hi Dustin,

    Thank you for your reply!

    That is exactly what I was looking for! I tried using the special variable %cd% to get the current directory and, since the batch file is already located at the project's root folder, it worked perfectly!
     
  5. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Awesome, glad to hear it. :) I couldn't remember for sure whether %cd% included the trailing slash or not but I figured you'd figure it out.
     
  6. jimrogerz

    jimrogerz

    Joined:
    Aug 8, 2013
    Posts:
    6
    %cd% is an environment variable that only works when running unity from a Windows command prompt. From a bash prompt (Git for Windows/OSX terminal) use $PWD
     
    schmidt_ugd likes this.
  7. SimonCVintecc

    SimonCVintecc

    Joined:
    Jun 4, 2019
    Posts:
    8
    If, on windows, you want the exact same path as the folder from which you run the bat file, you can use %~dp0