I’d like to submit a feature request for Feature:
Ability to open a Unity project, in the proper editor version, without the CLI command needing to contain anything other than the path to the Unity Hub (constant) + path-to-project.
Additional to open I wish I could just add path of project to unity hub
Actually it should have all command relate to project. Add / List / Open / Remove
With the same pattern as editors command it should be unityhub -- --headless projects -listunityhub -- --headless projects -add "path"unityhub -- --headless projects -open "path"
And open command should have version enforcer such as --unityversion=2022.3.5f and preemtive prompt, such as --switchversion=true and --error=ignore or --error=safemode
Until someone at unity gets around to it, here’s a script to open the project from the correct hub editor version
# 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 &
productboard is very unwieldy. It even cannot login with unity id and instead need to put email manually. And we can’t comment anything on it is paint point
With my new unity-cli npm package it is as simple as: unity-cli open-project if you’re in the working directory of your unity project, otherwise unity-cli open-project -p /path/to/your/unity/project.