Version: 2019.1
故障排除
创建自定义包

网络问题

配置防火墙

确保 Unity Package Manager 可以使用 HTTPS 访问以下域名:

  • packages.unity.com
  • download.packages.unity.com
  • upm-cdn.unity.com(对于中国的地点,则是 upm-cdn-china.unitychina.cn)

Add the above domain names to your firewall’s whitelist.

配置代理服务器

使用代理服务器时,请配置 Unity Package Manager 的 HTTP_PROXYHTTPS_PROXY 环境变量(用于针对 Unity 包注册表执行请求)。

您可以根据操作系统来全局设置这些变量(系统变量或用户变量)。或者,您可以仅为 Unity Hub 设置环境变量(在 Unity Hub 启动后)。

In some corporations and institutions, users are behind a firewall and can only access the internet through a proxy. Some proxies unpack the HTTPS content and repack it with its own self-signed certificate. Unity Package Manager’s underlying HTTPS layer rejects these self-signed certificates because it does not recognize them, and treats the connection as a possible man-in-the-middle attack. This means that you can’t use the Package Manager in Unity if your proxy uses a self-signed certificate.

为 Unity Hub 设置环境变量

本节说明了如何创建一个可从 Windows 命令提示符macOS 或 Linux 终端运行的命令文件。或者,也可以将命令直接复制并粘贴到提示窗口或终端窗口中。

NOTE: Before you run the command file, shut down the Hub completely. If the Hub is already running, the script switches focus to the Hub without relaunching, so it does not apply the changed proxy settings.

Windows

请按照以下说明在 Windows 上创建一个命令文件。

该文件将启动设置了环境变量的 Hub。您可以双击文件,也可以从命令提示符调用文件。Unity 将这些环境变量传递给从 Hub 启动的任何 Unity Editor 进程。

1.打开一个文本编辑器,如记事本。

2.输入以下文本,将 proxy-url 替换为正确的代理服务器 URL,并根据需要调整 Hub 安装路径:

```powershell
@echo off
set HTTP_PROXY=proxy-url
set HTTPS_PROXY=proxy-url
start "" "C:\Program Files\Unity Hub\Unity Hub.exe"

```

**NOTE:** If there are spaces in the path, you must use double quotes around the path to the program.

3.将文件保存到易于找到的位置(例如 Desktop),并确保文件具有 .cmd 后缀(例如 launchUnityHub.cmd)。

macOS

请按照以下说明在 macOS 上创建 launchUnityHub.command 文件。

该文件将启动设置了环境变量的 Hub。您可以双击文件,也可以从 Bash 终端调用文件。Unity 将这些环境变量传递给从 Hub 启动的任何 Unity Editor 进程。

NOTE: Double-clicking the command file opens a Terminal window or tab and leaves it open, even after the script finishes. You can change this behavior in the preferences for the Terminal.app.

1.打开终端窗口。

2.输入以下脚本,将 proxy-url 替换为正确的代理服务器 URL,并根据需要调整 Hub 安装路径:

```bash
echo '#!/bin/bash
export HTTP_PROXY=proxy-url
export HTTPS_PROXY=proxy-url
nohup "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub" &>/dev/null &' > launchUnityHub.command
chmod +x launchUnityHub.command
```

**NOTE:** If there are spaces in the path, you must use double quotes around the path to the program.

3.如果愿意,可以将 launchUnityHub.command 文件移动到方便的位置(例如,Desktop)。

故障排除
创建自定义包