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:
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 (
):
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.
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.
这种评估称为依赖关系解析,大致遵循以下逻辑:
1.选择直接依赖项的版本。 2.如果没有直接依赖项,并且这是__内置包__版本,则选择内置版本。 3.如果没有直接依赖项,并且这不是内置包版本,则检查这是不是多个包的间接依赖项: * If this is an indirect dependency of only one package in the Project, there is no conflict, so select the higher of these versions: * 此间接依赖项的版本 * Unity 需要的最低版本 * 如果出现多个间接依赖项,而且这些间接依赖项请求多个版本,则可能会产生冲突。Package Manager 可以使用自动冲突解决策略来解决大多数冲突。
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.