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

Get unity ProjectPath via command line

Discussion in 'Scripting' started by petarjnordeus, Apr 13, 2022.

  1. petarjnordeus

    petarjnordeus

    Joined:
    Feb 3, 2018
    Posts:
    7
    Is there any way to retrieve the currently opened project path, via command line, windows powerShell or some other way?

    (I want to get it from an external program, so I could automatically set/change some things in the unity's Editor folder)

    thank you
     
  2. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    777
    How about right click on the project i the Unity Hub application to reveal it in the file system?
     
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,019
    if you parse Editor.log, it has project path and unity exe path (for most recent opened unity editor/project)
    upload_2022-4-14_14-36-36.png
    https://docs.unity3d.com/Manual/LogFiles.html

    note: if you open another project, that will overwrite the main editor.log
     
    petarjnordeus and Bunny83 like this.
  4. petarjnordeus

    petarjnordeus

    Joined:
    Feb 3, 2018
    Posts:
    7
    @
    yes, I saw that one... the problem with it is if you open multiple instances of unity - different projects, different versions of unity, they all use the same log. so you cannot know projects for each instance :(

    I went on to try and dig the registry - where the "RecentlyUsedProjectPath" are stored. Its "EditorPrefs" memory basically. It stores the last 7 project paths, but its the same problem. all instances of unity use the same registry, at least for those project paths. Thinking about it now, i could maybe check to see which instance is opened 1st, then 2nd, 3rd etc... and match it with the data from the registry...
     

    Attached Files:

  5. petarjnordeus

    petarjnordeus

    Joined:
    Feb 3, 2018
    Posts:
    7
    im trying to create navigation live link between 3ds Max and Unity, which i got working, but I want to add a drop down to chose which unity window to connect to...
     

    Attached Files:

    mgear likes this.
  6. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,019
    if you already have some custom scripts running on those unity projects,
    unity could output textfile somewhere (at editor start maybe) that contains info..

    or if you use sockets/ports, max could query project paths there?
     
    Joe-Censored likes this.
  7. petarjnordeus

    petarjnordeus

    Joined:
    Feb 3, 2018
    Posts:
    7
    that is a good idea! Ill try something like that...

    yes, I already have an editor script reading a json file that is located in StreamingAssets - thats where max is outputing the data on its viewport change.
     
  8. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,739
    if doing this for a live link, feel like i would try setup a socket server and client or something similar. I have made similar things between IDE's and 3d packages like Maya before. Can be a lot faster to respond if doing it this way, and not have to rely on the file system.
     
    Last edited: Apr 14, 2022
    petarjnordeus likes this.