Version: 2019.3
Accessing package Assets
依赖关系

项目清单

When Unity loads a Project, the Unity Package Manager reads the Project manifest so that it can compute a list of which packages to load. When a user installs or uninstalls a package through the Package Manager window, the Package Manager stores those changes in the Project manifest file. The Project manifest file manages the list of packages through the dependencies object.

In addition, the Project manifest serves as a configuration file for the Package Manager. It stores the location of one or more package registries. For Git packages, it also provides a lock object defining a commit hash and revision number to guarantee that the Package Manager always installs exactly the same dependencies.

You can find the Project manifest file, called manifest.json, in the Packages folder under the root folder of your Unity Project. Like the package manifest file, the Project manifest file uses JSON (JavaScript Object Notation) syntax.

属性

All attributes are optional. However, if your Project manifest file does not contain any values, the Package Manager window doesn’t load, and the Package Manager doesn’t load any packages.

Tip: At any time, you can fix any problems with your registry by choosing Reset packages to defaults from the main Unity Help menu. However, be aware that this action resets all changes you made to the packages in your Project so it is best to use this strategy as a last resort.

JSON 类型 描述
dependencies 对象 项目中可用包的列表。清单中的此条目使用映射结构列出与项目所需版本关联的包名称

请参阅依赖关系部分了解有关所有受支持模式的更详细概述。

注意:该列表不包括间接依赖项(也就是其他包需要的包)。
registry String Unity Package Manager 主注册表的 URL。这将覆盖默认的注册表 URL (https://packages.unity.com)。

注意:如果您用自己的注册表覆盖默认注册表,则会失去对官方 Unity 包的访问权限。但如果您想使用自己的私有包集合来扩充 Unity 包库,请设置 scopedRegistries 属性以改用某一范围内的注册表。
scopedRegistries 对象数组 指定除了默认注册表之外的自定义注册表。这样允许您托管自己的包。

请参阅范围注册表一节以了解更多详细信息。
lock 对象 用提交哈希和所选修订版本描述 Git 包解析信息。Package Manager 将自动更新此属性。这样可以保证 Package Manager 安装完全相同的依赖项。

该属性是为 Git 包保留的属性,但是其他功能未来可能会使用该属性,以保证确定性的包版本解析。
testables 字符串数组 列出您要包含在 Unity Test Runner 中的包名称。有关更多信息,请参阅向包添加测试

项目清单示例

{
  "registry": "https://my.registry.com",
  "scopedRegistries": [{
    "name": "My internal registry",
    "url": "https://my.internal.registry.com",
    "scopes": [
      "com.company"
    ]
  }],
  "dependencies": {
    "com.unity.package-1": "1.0.0",
    "com.unity.package-2": "2.0.0",
    "com.unity.package-3": "3.0.0",
    "com.unity.my-local-package": "file:/path/to/com.unity.my-local-package",
    "com.unity.my-git-package": "https://my.repository/my-package.git#v1.2.3"
  },
  "lock": {
    "com.unity.my-git-package": {
       "hash": "9e72f9d5a6a3dadc38d813d8399e1b0e86781a49",
       "revision": "v1.2.3"
    }
  },
  "testables": [ "com.unity.package-1", "com.unity.package-2" ]
}
Accessing package Assets
依赖关系
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961