Unity Hub はバージョン 2.1 以降は CLI で様々な処理が使えます。
unity3d.com
ヘルプの確認方法
どんな事ができるのかはヘルプで確認できます。
■ Windows の場合
Unity Hub がインストールされているフォルダに移動して以下のコマンドを実行。
"Unity Hub.exe" -- --headless help
デフォルトの場所にインストールしている場合は以下のコマンド。
"C:\Program Files\Unity Hub\Unity Hub.exe" -- --headless help
■ Mac の場合
以下のコマンドを実行。
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless help
Unity Hub 2.4.5 でヘルプコマンドを実行した場合の結果はこちら。
Commands: editors description: list the releases and installed editors alias: e example: Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless editors -r options: [default] list of available releases and installed editors on your machine combined --releases|-r only list of available releases promoted by Unity --installed|-i only list of installed editors on your machine install-path description: set/get the path where the Unity editors will be installed alias: ip example: Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless ip -s /Applications/Unity/Hub/Editor/ options: --set|-s <path> set the install path to the given path --get|-g returns the install path install description: installs a new editor either from the releases list or archive alias: i example: Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2019.1.11f1 --changeset 9b001d489a54 options: --version|-v <version> editor version to be installed (e.g. 2019.1.11f1) - required --changeset|-c <changeset> changeset of the editor if it is not in the release list (e.g. 9b001d489a54) - required if the version is not in the releases. see editors -r --module|-m <moduleid> see install-modules for more information install-modules description: download and install a module (e.g. build support) to an installed editor alias: im example: Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2019.1.11f1 -m ios -m android options: --version|-v <version> version of the editor to add the module to - required --module|-m <moduleid> the module id. The followings are the available values depending on version. You can specify multiple values. Documentation: documentation Standard Assets: standardassets Example Project: example Android Build Support: android iOS Build Support: ios tvOS Build Support: appletv Linux Build Support: linux-mono SamsungTV Build Support: samsung Tizen Build Support: tizen WebGL Build Support: webgl Windows Build Support: windows Facebook Gameroom Build Support: facebook-games MonoDevelop / Unity Debugger: monodevelop Vuforia Augmented Reality Support: vuforia-ar Language packs: language-ja, language-ko, language-zh-cn, language-zh-hant, language-zh-hans Mac Build Support (IL2CPP): mac-il2cpp Windows Build Support (Mono): windows-mono Android SDK & NDK Tools: android-sdk-ndk-tools OpenJDK: android-open-jdk Lumin OS (Magic Leap) Build Support: lumin --childModules|--cm automatically installs all child modules of selected modules
使い方
使い方としては先程のヘルプを表示する時のコマンド文の help の部分を実行したいコマンドに差し替える事で希望するコマンドを実行できます。
■ Windows の場合
Unity Hub がインストールされているフォルダに移動して以下のコマンドを実行。
"Unity Hub.exe" -- --headless (ここに実行したいコマンド)
■ Mac の場合
以下のコマンドを実行。
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless (ここに実行したいコマンド)
ここでは例としてインストール済みの Unity 一覧を取得してみます。
先程のヘルプを確認するとコマンドは editors でエイリアスは e 。オプションは --installed で、短縮の場合は -i だと分かります。
そのため、実行すべきコマンドはこちらになります。
■ Windows の場合
Unity Hub がインストールされているフォルダに移動して以下のコマンドを実行。
"Unity Hub.exe" -- --headless e -i
■ Mac の場合
以下のコマンドを実行。
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless e -i