Version: 2019.3
Unity 的 Package Manager
全局缓存

概念

本节介绍有关 Unity Package Manager 功能的许多概念:

版本

每个包都有多个版本,标记了该包在自身的生命周期中所经历的更改。每次开发人员更新包时,都会为该包提供一个新的版本号。包版本的更改会告诉您这次更改包含了重大更改(主要)、新的向后兼容功能(次要)还是仅错误修复(补丁),并遵循语义版本控制

要查看特定包可用的版本列表,请参阅查找特定版本

清单

清单文件有两种类型:

  • 项目清单 (manifest.json)。项目清单存储 Package Manager 在查找和加载正确的包时所需的信息,并列出声明为依赖项的包和版本。
  • 包清单 (package.json)。包清单存储有关特定包的信息,并列出该包所需的包和版本。

这两种文件都使用 JSON(JavaScript 对象表示法)语法。

注册表

Unity maintains a central registry of official packages that are available for distribution. A package registry stores package contents and information (metadata) on each package version. By default, all Projects use the official Unity package registry, but you can add additional registries to store and distribute private packages or stage packages in development.

包管理

Unity Package Manager 是管理整个包系统的工具。此工具的主要任务包括:

  • 与 Unity 注册表以及您指定的任何其他注册表通信。
  • It reads your Project manifest and fetches package contents and metadata.
  • It installs, upgrades, and uninstalls packages, whether they are dependencies of the Project or one of the installed packages.
  • 启用和禁用 Unity 的内置包。
  • 显示有关每个包的每个版本的信息。
  • It resolves conflicts when the Project and its packages require more than one package version.

The Unity Package Manager installs samples, tools, and Assets on a per-Project basis, rather than installing them across all Projects for a specific machine or device. It uses a global cache to store downloaded package metadata and contents. Once installed, Unity treats package Assets just like any other Asset in the Project, except that these Assets are stored inside the package folder and are immutable. You can only permanently change content from Local and Embedded package sources.

Package states

States indicate where the package is in the development cycle:

状态 描述
开发中 (In Development) The package developer is still creating the package. Usually this corresponds to having the package embedded in the developer’s Project.
预览 (Preview) The package is ready to use and can appear in the package registry, but it is not ready for use in production. This stage is like a beta cycle.
Production-ready The package is safe to use in production and the developer has published it to the package registry.
已验证 (Verified) The package has undergone testing and has been verified to work safely with a specific version of Unity, and all other packages verified for that version.

The Package Manager window displays a tag that corresponds to some of these states. For more information, see Tags.

包来源

来源描述了包的来源:

来源 描述
注册表 The Unity Package Manager downloads most packages from a package registry into a global cache on your computer as you request them. These packages are immutable, so you can use them in your Project, but you cannot modify them or change their package manifests.
内置 These packages allow you to enable or disable Unity features (for example, Terrain Physics, Animation, etc.). They are immutable.
嵌入式 Any package stored inside your Project folder is embedded. This source corresponds with the in development state because you typically put all the scripts, libraries, samples, and other Assets your new package needs in a folder under your Project folder when you begin development on a package.
本地 可从计算机上的任何文件夹中安装安装包(例如,如果在本地克隆了开发代码仓库)。
本地 tarball 可通过计算机上的 tarball 文件来安装包。Package Manager 从 tarball 中提取包并将其存储在缓存中。但是,与从本地文件夹安装不同,这些包是不可变的。
Git Package Manager 直接从 Git 代码仓库安装 Git 包,而不是从注册表服务器进行安装。

要编辑包的包清单,请参阅检查包

Package Manager 窗口会显示与上述某些来源对应的标签。有关更多信息,请参阅标签

Unity 的 Package Manager
全局缓存