Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 32 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ A powerful command line utility for the Unity Game Engine. Automate Unity projec
- [License Version](#license-version)
- [Activate License](#activate-license)
- [Return License](#return-license)
- [License Context](#license-context)
- [Licensing Logs](#licensing-logs)
- [Unity Hub](#unity-hub)
- [Hub Version](#hub-version)
- [Hub Path](#hub-path)
- [Unity Hub Install](#unity-hub-install)
- [Run Unity Hub Commands](#run-unity-hub-commands)
- [Unity Editor](#unity-editor)
- [Setup Unity Editor](#setup-unity-editor)
- [Uninstall Unity Editor](#uninstall-unity-editor)
- [Unity Editor](#unity-editor)
- [Run Unity Editor Commands](#run-unity-editor-commands)
- [List Project Templates](#list-project-templates)
- [Create Unity Project](#create-unity-project)
- [Open Unity Project](#open-unity-project)
- [Run Unity Editor Commands](#run-unity-editor-commands)
- [Unity Editor Logs](#unity-editor-logs)
- [Unity Package Manager](#unity-package-manager)
- [Sign a Unity Package](#sign-a-unity-package)
- [Logging](#logging)
Expand Down Expand Up @@ -110,15 +113,15 @@ unity-cli activate-license --license personal --email <your-email> --password <y
unity-cli return-license --license personal
```

#### License Context
##### License Context

`license-context`: Prints the current license context information.

```bash
unity-cli license-context
```

#### Licensing Logs
##### Licensing Logs

`licensing-logs`: Prints the path to the Unity Licensing Client log files.

Expand Down Expand Up @@ -177,8 +180,6 @@ Gets a list of installed editors:
unity-cli hub editors --installed
```

#### Unity Editor

##### Setup Unity Editor

`setup-unity [options]`: Find or install the Unity Editor for a project or specific version.
Expand Down Expand Up @@ -213,6 +214,28 @@ unity-cli setup-unity --unity-version 6000 --modules android,ios
unity-cli uninstall-unity --unity-version 6000
```

#### Unity Editor

##### Run Unity Editor Commands

`run [options] <args...>`: Run Unity Editor command line arguments (passes args directly to the editor).

- `--unity-editor <unityEditor>` The path to the Unity Editor executable. If unspecified, `--unity-project` or the `UNITY_EDITOR_PATH` environment variable must be set.
- `--unity-project <unityProject>` The path to a Unity project. If unspecified, the `UNITY_PROJECT_PATH` environment variable will be used, otherwise no project will be specified.
- `--log-name <logName>` The name of the log file.
- `--log-level <logLevel>` Override the logger verbosity (`debug`, `info`, `minimal`, `warning`, `error`). Defaults to `info`.
- `--verbose` Enable verbose logging. (Deprecated, use `--log-level <value>` instead)
- `<args...>` Arguments to pass directly to the Unity Editor executable.

> [!NOTE]
> When setting the `--log-level` option to `minimal`, only the unity telemetry logs will be shown in the console output. All other logs will be written to the log file. This option is only supported when running the command locally in the terminal. ***This options is still experimental and may change in future releases.***
>
> When running in CI environments the logger will automatically print the full logs to the console no matter the log level.

```bash
unity-cli run --unity-project <path-to-project> -quit -batchmode -executeMethod StartCommandLineBuild
```

##### List Project Templates

> [!NOTE]
Expand Down Expand Up @@ -274,24 +297,12 @@ unity-cli open-project --unity-project <path-to-project> --unity-version 6000 --
unity-cli open-project
```

##### Run Unity Editor Commands
##### Unity Editor Logs

`run [options] <args...>`: Run Unity Editor command line arguments (passes args directly to the editor).

- `--unity-editor <unityEditor>` The path to the Unity Editor executable. If unspecified, `--unity-project` or the `UNITY_EDITOR_PATH` environment variable must be set.
- `--unity-project <unityProject>` The path to a Unity project. If unspecified, the `UNITY_PROJECT_PATH` environment variable will be used, otherwise no project will be specified.
- `--log-name <logName>` The name of the log file.
- `--log-level <logLevel>` Override the logger verbosity (`debug`, `info`, `minimal`, `warning`, `error`). Defaults to `info`.
- `--verbose` Enable verbose logging. (Deprecated, use `--log-level <value>` instead)
- `<args...>` Arguments to pass directly to the Unity Editor executable.

> [!NOTE]
> When setting the `--log-level` option to `minimal`, only the unity telemetry logs will be shown in the console output. All other logs will be written to the log file. This option is only supported when running the command locally in the terminal. ***This options is still experimental and may change in future releases.***
>
> When running in CI environments the logger will automatically print the full logs to the console no matter the log level.
`editor-logs`: Prints the path to the Unity Editor log files.

```bash
unity-cli run --unity-project <path-to-project> -quit -batchmode -executeMethod StartCommandLineBuild
unity-cli editor-logs
```

#### Unity Package Manager
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rage-against-the-pixel/unity-cli",
"version": "1.6.2",
"version": "1.6.3",
"description": "A command line utility for the Unity Game Engine.",
"author": "RageAgainstThePixel",
"license": "MIT",
Expand Down
8 changes: 8 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,14 @@ program.command('open-project')
}
});

program.command('editor-logs')
.description('Prints the path to the Unity Editor log files.')
.action(async (options) => {
const unityEditorLogsPath = UnityEditor.GetEditorLogsDirectory();
process.stdout.write(`${unityEditorLogsPath}\n`);
process.exit(0);
});

program.commandsGroup("Unity Package Manager:");

program.command('sign-package')
Expand Down
18 changes: 18 additions & 0 deletions src/unity-editor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as os from 'os';
import * as fs from 'fs';
import * as path from 'path';
import { Logger } from './logging';
Expand Down Expand Up @@ -446,6 +447,23 @@ export class UnityEditor {
return editorRootPath;
}

/**
* Gets the path to the Unity Editor log directory.
* @returns The path to the Unity Editor logs directory.
*/
static GetEditorLogsDirectory() {
switch (process.platform) {
case 'darwin':
return path.join(os.homedir(), 'Library', 'Logs', 'Unity');
case 'linux':
return path.join(os.homedir(), '.config', 'unity3d', 'Editor');
case 'win32':
return path.join(process.env.LOCALAPPDATA || '', 'Unity', 'Editor');
default:
throw new Error(`Unsupported platform: ${process.platform}`);
}
}

/**
* Uninstall the Unity Editor.
*/
Expand Down
Loading