1.4.1 • Published 1 year ago

@akiojin/unity-command v1.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

unity-command

A package to control Unity from the command line.

Installation

npm install @akiojin/unity-command

Usage

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())

Reference

class UnityUtils

static GetCurrentUnityVersion(projectDirectory: string): string

Description

Returns the Unity version set for the given project.

Arguments
NameTypeDescription
projectDirectorystringUnity project directory path.
Return
TypeDescription
stringUnity version. (e.g. 2021.2.7f1)

static GetUnityPath(unityVersion: string): string

Description

Get the path to the Unity editor executable.

Arguments
NameTypeDescription
unityVersionstringUnity version to be used
installDirectorystringUnity 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.

Return
TypeDescription
stringUnity app path (e.g. /Applications/Unity/Hub/Editor/2021.2.7f1/Unity.app/Contents/MacOS/Unity)

class UnityCommandBuilder

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

DisableGPUSkinning(): void

Description

Disable Graphics Processing Unit (GPU) skinning at startup.

SetExecuteMethod(executeMethod: string): void

Description

Execute the static method as soon as Unity opens the project, and after the optional Asset server update is complete.

Arguments
NameTypeDescription
executeMethodstring<ClassName.MethodName> or <NamespaceName.ClassName.MethodName>

SetJobWorkerCount(count: number): void

Description

Specify the maximum thread count for the Unity JobQueue Job Worker Count.

Arguments
NameTypeDescription
countnumberthe Unity JobQueue Job Worker Count.

SetLogFile(logFile: string): void

Description

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.

Arguments
NameTypeDescription
logFilestringPath name

DisableUPM() : void

Description

Disable the Unity Package Manager.

Activation(username: string, password: string): void

Description

Activate the Unity Editor.

Arguments
NameTypeDescription
usernamestringEnter a username into the log-in form during the activation of the Unity Editor.
passwordstringEnter a password into the log-in form during the activation of the Unity Editor.

SetProjectPath(projectPath: string): void

Description

Open the project at the given path. If the pathname contains spaces, enclose it in quotes.

Arguments
NameTypeDescription
projectPathstringProject path

EnableReleaseCodeOptimization(): void

Description

Enables release code optimization mode, overriding the current default code optimization mode for the session.

EnableAPIUpdater(): void

Description

Use this command line option to specify that APIUpdater should run when Unity is launched in batch mode.

SetBuildTarget(target: string): void

Description

Select an active build target before loading a project.

Arguments
NameTypeDescription
targetstringStandalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch,tvOS

EnableCacheServer(endpoint: string): void

Description

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.

Arguments
NameTypeDescription
endpointstringSpecifies the endpoint address if you are using the newer Accelerator Cache Server.Example: 127.0.0.1:10080.

DisableManagedDebugger(): void

Description

Disables the debugger listen socket.

EnableDebugCodeOptimization(): void

Description

Enables debug code optimization mode, overriding the current default code optimization mode for the session.

SetStackTraceLogType(type: string): void

Description

Allow detailed debugging. All settings allow None, Script Only and Full to be selected.

Arguments
NameTypeDescription
typestring"None" or "Script Only" or "Full"

Append(arg: string): void

Append(arg: string, param: string): void

Append(args: string[]): void

Append(arg: string | string[], param?: string): void

Description

Add an argument.

Arguments
NameTypeDescription
argstring | string[]Commands to pass to the Unity command line
param?stringParameters to be added to the command

Build(): string[]

Description

Returns an array of arguments to be passed to the command line.

Return
TypeDescription
string[]Argument array
1.4.1

1 year ago

1.3.0

2 years ago

1.2.9

2 years ago

1.2.10

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago