Version: 2021.3
为资源包创建示例
版本控制

包清单

Unity uses a package manifest file (package.json) to manage information about a specific version of a specific package. The package manifest is always at the root of the package and contains crucial information about the package, such as its registered name and version number. It also defines useful information to communicate to the user, such as a user-friendly name that appears in the UI, a brief description of the package, and the earliest version of Unity the package is compatible with.

The package manifest uses the JSON (JavaScript Object Notation) syntax to describe what the package contains. The file’s format is similar to npm’s package.json format, but uses different semantics for some of its properties. Refer to the example for a sample package manifest file.

The Package Manager reads this manifest to find out what the package contains, how to unpack its contents, and what information to display the user in the Package Manager window. The manifest stores this information in a series of required, recommended, and optional properties.

必需属性

If these properties aren’t present, either the registry refuses the package when it’s published, or the Package Manager can’t fetch or load the package.

属性 JSON 类型 描述
name String The officially registered package name. This name must conform to the Unity Package Manager naming convention, which uses reverse domain name notation. For more information about the naming convention, see Naming your package.

Note: This is a unique identifier, not the user-friendly name that appears in the list view in the Package Manager window.
version string 包版本号 (MAJOR.MINOR.PATCH)。

例如,“3.2.1”表示这是第 3 个主要发行版、第 2 个次要发行版和第 1 个补丁。

该值必须遵守语义版本控制。有关更多信息,请参阅版本控制

Recommended properties

The Package Manager can install packages in a project even if the recommended properties don’t have valid values or are missing.

However, you should assign values for these properties to ensure that your package is discoverable and to provide a better experience for users.

属性 JSON 类型 描述
description String A brief description of the package. This is the text that appears in the details view of the Package Manager window. This field supports UTF–8 character codes. This means that you can use special formatting character codes, such as line breaks (\n) and bullets (\u25AA).
displayName String 一个显示在 Unity Editor 中的用户友好名称(例如,显示在 Project Browser 中、Package Manager 窗口中,等等)。

例如,Unity TimelineProBuilderIn App Purchasing
unity String Indicates the lowest Unity version the package is compatible with. If omitted, the Package Manager considers the package compatible with all Unity versions.

The expected format is “<MAJOR>.<MINOR>” (for example, 2018.3). To point to a specific patch, use the unityRelease property as well.

Note: A package that isn’t compatible with Unity doesn’t appear in the Package Manager window.

可选属性

These properties are optional, meaning that you can omit them. However, if they’re present, they must have a valid value.

属性 JSON 类型 描述
author 对象 The author of the package.

This object contains one required field, name, and two optional fields, email and url.

For example:
{ "name" : "John Doe",
   "email" : "john.doe@example.com",
   "url" : "http://john.doe.example.com/"
}
changelogUrl String Custom location for this package’s changelog specified as a URL. For example:
"changelogUrl": "https://example.com/changelog.html"

Note: When the Package Manager can’t reach the URL location (for example, if there is a network issue), it does the following:

- If the package is installed, the Package Manager opens a file browser displaying the CHANGELOG.md file in the package cache.
- If the package isn’t installed, the Package Manager displays a warning that an offline changelog isn’t available.
dependencies 对象 A map of package dependencies. Keys are package names, and values are specific versions. They indicate other packages that this package depends on.

Note: The Package Manager doesn’t support range syntax, only SemVer versions.
documentationUrl String Custom location for this package’s documentation specified as a URL. For example:
"documentationUrl": "https://example.com/"

Note: When the Package Manager can’t reach the URL location (for example, if there is a network issue), it does the following:

- If the package is installed, the Package Manager opens a file browser displaying the Documentation~ folder in the package cache.
- If the package isn’t installed, the Package Manager displays a warning that offline documentation isn’t available.
hideInEditor Boolean Package Manager hides most packages automatically (the implicit value is “true”), but you can set this property to “false” to make sure that your package and its assets are always visible.
keywords 字符串数组 Package Manager 搜索 API 使用的关键字数组。这可以帮助用户找到相关的包。
license String OSS 许可证的标识符使用 SPDX 标识符格式,或一个字符串,如 “See LICENSE.md file”。

注意:如果您在包清单中省略此属性,则您的包必须包含一个 LICENSE.md 文件。
licensesUrl String Custom location for this package’s license information specified as a URL. For example:
"licensesUrl": "https://example.com/licensing.html"

Note: When the Package Manager can’t reach the URL location (for example, if there is a network issue), it does the following:

- If the package is installed, it opens a file browser displaying the LICENSE.md file in the package cache.
- If the package isn’t installed, the Package Manager displays a warning that offline license information isn’t available.
samples 对象数组 包中包含的示例列表。每个示例都包含一个显示名称、一条描述以及示例文件夹的路径,该路径从 Samples~ 文件夹本身开始:

{
   "displayName": "<name-to-appear-in-the-UI>",
   "description": "<brief-description>",
   "path": "Samples~/<sample-subfolder>"
}

有关更多信息,请参阅为包创建示例
type String 为 Package Manager 提供其他信息的常量。

保留仅供内部使用。
unityRelease String Part of a Unity version indicating the specific release of Unity that the package is compatible with. You can use this property when an updated package requires changes made during the Unity alpha/beta development cycle. This might be the case if the package needs newly introduced APIs, or uses existing APIs that have changed in a non-backward-compatible way without API Updater rules.

The expected format is “<UPDATE><RELEASE>” (for example, 0b4).

Note: If you omit the recommended unity property, this property has no effect.

A package that isn’t compatible with Unity doesn’t appear in the Package Manager window.

包清单示例

{
  "name": "com.[company-name].[package-name]",
  "version": "1.2.3",
  "displayName": "Package Example",
  "description": "This is an example package",
  "unity": "2019.1",
  "unityRelease": "0b5",
  "documentationUrl": "https://example.com/",
  "changelogUrl": "https://example.com/changelog.html",
  "licensesUrl": "https://example.com/licensing.html",
  "dependencies": {
    "com.[company-name].some-package": "1.0.0",
    "com.[company-name].other-package": "2.0.0"
 },
 "keywords": [
    "keyword1",
    "keyword2",
    "keyword3"
  ],
  "author": {
    "name": "Unity",
    "email": "unity@example.com",
    "url": "https://www.unity3d.com"
  }
}


为资源包创建示例
版本控制
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961