Version: 2019.3
Project manifest
Embedded dependencies

Dependencies

The dependencies attribute in the Project manifest is a JSON object that maps a package name to a version. The version number indicates which version of the package to download from the package registry. For example:

{
  "dependencies": {
    "com.my-package": "2.3.1",
    "com.my-other-package": "1.0.1-preview.1",
       etc.
  }
}

In addition to using version numbers, the Package Manager also supports adding Project dependencies with the following:

Direct and indirect dependencies

A direct dependency is a Project-level dependency. When you install a package through the Package Manager window, or manually edit the Project manifest.json file to explicitly add a dependency, you are creating a direct package dependency ():

Direct dependency (A): a package request from the Project manifest
Direct dependency (A): a package request from the Project manifest

Packages can declare their own dependencies to other packages. Such package dependencies become indirect (), or transitive, dependencies of your Project when you install the package.

Indirect dependency (B): a package request from another packages manifest
Indirect dependency (B): a package request from another package’s manifest

The Package Manager determines which version of each package to install, no matter how it becomes a dependency of your Project. To do this, it prioritizes direct dependencies over indirect dependencies, as long as the higher priority version doesn’t violate any other requirements.

This evaluation is called dependency resolution, and roughly follows this logic:

  1. Select the version of the direct dependency.
  2. If there is no direct dependency and this is a built-in package version, select the built-in version.
  3. If there is no direct dependency and this is not a built-in version, check whether this is an indirect dependency of more than one package:
    • If this is an indirect dependency of only one package in the Project, there is no conflict, so select the higher of these versions:
      • This indirect dependency’s version
      • The minimum version required by Unity
    • If multiple indirect dependencies occur, that might create a conflict if the indirect dependencies request more than one version. The Package Manager can resolve most conflicts with an automatic conflict resolution strategy.

In any case, you can manually override these resolution strategies. To do this, request a specific version in the Project manifest (either by installing from the Package Manager window or by editing the manifest directly). This creates a direct dependency, which takes precedence over any resolution strategy.

Project manifest
Embedded dependencies
Copyright © 2020 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961