Command to open UnityEditor and Project directly

Hi,

Is there a command to open UnityProject with respective UnityEditor without opening UnityHub on linux?

I tired running “./Unity projectpath” in installed Editor folder but it automatically opens UnityHub to choose the project.

Thank you!

1 Like

Try this:

./Unity -projectPath /path/to/project
1 Like

Great! That works, thank you so much!

Hello I’m sorry being a noob on linux but I created a .sh file to open Unity project but I failed :slight_smile:

I tried like documentation said openning a project like this :

/Applications/Unity/Hub/Editor/<version>/Unity.app/Contents/Linux/Unity -projectPath <project path>

But it doesn’t seems to worked, I saw that path to Unity looks like this :
/home/user/Unity/Hub/Editor/2021.3.4f1/Editor/Unity

So I tried this that doesn’t work too:

/home/user/Unity/Hub/Editor/2021.3.4f1/Editor/Unity -projectPath <projectpath>

I’m quite lost, it’s perfectly working on windows but with my ubuntu I can’t find a way.

This isn’t the correct path. Unity editors are installed inside the Unity directory in your home directory.

./Unity/Hub/Editor/2021.3.26f1/Editor/Unity -projectPath ./Projects/MyProject

That works.

Here’s a script to automatically get the right unity version from the hub

# Launch a unity project with the right editor

# The current working directory has to be the root of the project
# cd /path/to/UnityProject
HUB_PATH="C:\Program Files\Unity Hub\Unity Hub.exe"

# Extract into variable via sed
PROJECT_VERSION=$(sed -nE 's/m_EditorVersion: (.+)/\1/p' ProjectSettings/ProjectVersion.txt)

# Display
echo "$PROJECT_VERSION"

# Get hub version

# editors - i :
#2021.X.Xf1 , installed at C:\Program Files\Unity\Hub\Editor\2021.X.Xf1\Editor\Unity.exe
#2022.X.Xf1 , installed at C:\Program Files\Unity\Hub\Editor\2022.X.Xf1\Editor\Unity.exe
#2023.X.Xf1 , installed at C:\Program Files\Unity\Hub\Editor\2023.X.Xf1\Editor\Unity.exe

# grep "$PROJECT_VERSION"
# 2022.X.Xf1 , installed at C:\Program Files\Unity\Hub\Editor\2022.X.Xf1\Editor\Unity.exe

# cut -d\  -f5-
# C:\Program Files\Unity\Hub\Editor\2022.X.Xf1\Editor\Unity.exe

PROJECT_VERSIONS=$("$HUB_PATH" -- --headless editors -i)

PROJECT_PATH=$(echo "$PROJECT_VERSIONS" | grep "$PROJECT_VERSION" | cut -d\  -f5-)

# Display

echo "$PROJECT_PATH"

# Launch Unity

nohup "$PROJECT_PATH" -projectPath . >/dev/null 2>&1 &