A package to control Unity from the command line.
npm install @akiojin/unity-command
import { Unity, UnityCommandBuilder } from '@akiojin/unity-command'
const builder = new UnityCommandBuilder()
builder
.SetBuildTarget('iOS')
.SetExecuteMethod('MyEditorScript.PerformBuild')
.Append([ '-CustomCommand', 'Param' ])
...
const exe = Unity.GetUnityPath('2021.2.7f1')
execa.execa(exe, builder.Build())
Returns the Unity version set for the given project.
Name | Type | Description |
---|---|---|
projectDirectory |
string |
Unity project directory path. |
Type | Description |
---|---|
string |
Unity version. (e.g. 2021.2.7f1) |
Get the path to the Unity editor executable.
Name | Type | Description |
---|---|---|
unityVersion |
string |
Unity version to be used |
installDirectory |
string |
Unity installation directory path. |
The installation directory, if omitted, is obtained from the environment variable UNITY_HUB_INSTALL_DIRECTORY. If the environment variable UNITY_HUB_INSTALL_DIRECTORY is not set, it is taken from the default installation directory.
Type | Description |
---|---|
string |
Unity app path (e.g. /Applications/Unity/Hub/Editor/2021.2.7f1/Unity.app/Contents/MacOS/Unity) |
The following parameters have already been added by default when the instance is created, so they do not need to be added.
-batchmode
-silent-crashes
Disable Graphics Processing Unit (GPU) skinning at startup.
Execute the static method as soon as Unity opens the project, and after the optional Asset server update is complete.
Name | Type | Description |
---|---|---|
executeMethod | string | <ClassName.MethodName> or <NamespaceName.ClassName.MethodName> |
Specify the maximum thread count for the Unity JobQueue Job Worker Count.
Name | Type | Description |
---|---|---|
count | number | the Unity JobQueue Job Worker Count. |
Specify where Unity writes the Editor or Windows/Linux/OSX standalone log file. To output to the console, specify - for the path name. On Windows, specify the - option to direct the output to stdout, which by default is not the console.
Name | Type | Description |
---|---|---|
logFile | string | Path name |
Disable the Unity Package Manager.
Activate the Unity Editor.
Name | Type | Description |
---|---|---|
username | string | Enter a username into the log-in form during the activation of the Unity Editor. |
password | string | Enter a password into the log-in form during the activation of the Unity Editor. |
Open the project at the given path. If the pathname contains spaces, enclose it in quotes.
Name | Type | Description |
---|---|---|
projectPath | string | Project path |
Enables release code optimization mode, overriding the current default code optimization mode for the session.
Use this command line option to specify that APIUpdater should run when Unity is launched in batch mode.
Select an active build target before loading a project.
Name | Type | Description |
---|---|---|
target | string | Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch,tvOS |
Tells Unity to use the newer Accelerator Cache Server. This overrides any configuration stored in the Editor Preferences. Use this to connect multiple instances of Unity to different Cache Servers.
Name | Type | Description |
---|---|---|
endpoint | string | Specifies the endpoint address if you are using the newer Accelerator Cache Server. Example: 127.0.0.1:10080. |
Disables the debugger listen socket.
Enables debug code optimization mode, overriding the current default code optimization mode for the session.
Allow detailed debugging. All settings allow None, Script Only and Full to be selected.
Name | Type | Description |
---|---|---|
type | string | "None" or "Script Only" or "Full" |
Add an argument.
Name | Type | Description |
---|---|---|
arg |
string | string[] | Commands to pass to the Unity command line |
param? |
string | Parameters to be added to the command |
Returns an array of arguments to be passed to the command line.
Type | Description |
---|---|
string[] |
Argument array |