{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/unity-upm-custom-package/",
  "atlas": "https://www.pystone.net/?node=unity-upm-custom-package#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/unity-upm-custom-package.md",
  "context": "https://www.pystone.net/notes/unity-upm-custom-package.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:unity-upm-custom-package",
  "slug": "unity-upm-custom-package",
  "title": "UPM自定义资源包及相关规范",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "UPM自定义资源包及相关规范 创建时间：2020/9/22 17:06",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "b37bb0f3b069e6b723af84317a848e7c2bdd8da805e29f6fd33c66a67631b01d",
  "assets": [],
  "headings": [
    {
      "depth": 1,
      "text": "UPM自定义资源包及相关规范",
      "anchor": "upm自定义资源包及相关规范",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#upm%E8%87%AA%E5%AE%9A%E4%B9%89%E8%B5%84%E6%BA%90%E5%8C%85%E5%8F%8A%E7%9B%B8%E5%85%B3%E8%A7%84%E8%8C%83"
    },
    {
      "depth": 2,
      "text": "UPM自定义资源包及相关规范",
      "anchor": "upm自定义资源包及相关规范-1",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#upm%E8%87%AA%E5%AE%9A%E4%B9%89%E8%B5%84%E6%BA%90%E5%8C%85%E5%8F%8A%E7%9B%B8%E5%85%B3%E8%A7%84%E8%8C%83-1"
    },
    {
      "depth": 2,
      "text": "UPM资源包介绍",
      "anchor": "upm资源包介绍",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#upm%E8%B5%84%E6%BA%90%E5%8C%85%E4%BB%8B%E7%BB%8D"
    },
    {
      "depth": 3,
      "text": "文件布局",
      "anchor": "文件布局",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#%E6%96%87%E4%BB%B6%E5%B8%83%E5%B1%80"
    },
    {
      "depth": 3,
      "text": "Package manifest",
      "anchor": "package-manifest",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#package-manifest"
    },
    {
      "depth": 4,
      "text": "Name",
      "anchor": "name",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#name"
    },
    {
      "depth": 4,
      "text": "Display Name",
      "anchor": "display-name",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#display-name"
    },
    {
      "depth": 4,
      "text": "版本号规范",
      "anchor": "版本号规范",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#%E7%89%88%E6%9C%AC%E5%8F%B7%E8%A7%84%E8%8C%83"
    },
    {
      "depth": 4,
      "text": "the lowest Unity version",
      "anchor": "the-lowest-unity-version",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#the-lowest-unity-version"
    },
    {
      "depth": 4,
      "text": "Package manifest example",
      "anchor": "package-manifest-example",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#package-manifest-example"
    },
    {
      "depth": 3,
      "text": "Assembly definition",
      "anchor": "assembly-definition",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#assembly-definition"
    },
    {
      "depth": 3,
      "text": "LICENSE相关（暂时忽略）",
      "anchor": "license相关暂时忽略",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#license%E7%9B%B8%E5%85%B3%E6%9A%82%E6%97%B6%E5%BF%BD%E7%95%A5"
    },
    {
      "depth": 2,
      "text": "步骤",
      "anchor": "步骤",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#%E6%AD%A5%E9%AA%A4"
    },
    {
      "depth": 3,
      "text": "1\\. 按照规范创建Package",
      "anchor": "1-按照规范创建package",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#1-%E6%8C%89%E7%85%A7%E8%A7%84%E8%8C%83%E5%88%9B%E5%BB%BApackage"
    },
    {
      "depth": 3,
      "text": "分发",
      "anchor": "分发",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#%E5%88%86%E5%8F%91"
    },
    {
      "depth": 4,
      "text": "zip",
      "anchor": "zip",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#zip"
    },
    {
      "depth": 4,
      "text": "Git代码库分发",
      "anchor": "git代码库分发",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#git%E4%BB%A3%E7%A0%81%E5%BA%93%E5%88%86%E5%8F%91"
    },
    {
      "depth": 2,
      "text": "README文档",
      "anchor": "readme文档",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#readme%E6%96%87%E6%A1%A3"
    },
    {
      "depth": 2,
      "text": "Changelog规范",
      "anchor": "changelog规范",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#changelog%E8%A7%84%E8%8C%83"
    },
    {
      "depth": 2,
      "text": "Semantic Versioning规范",
      "anchor": "semantic-versioning规范",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#semantic-versioning%E8%A7%84%E8%8C%83"
    },
    {
      "depth": 2,
      "text": "Ref",
      "anchor": "ref",
      "citation": "https://www.pystone.net/notes/unity-upm-custom-package/#ref"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:game-graphics-and-runtime",
      "title": "游戏图形与运行时",
      "url": "https://www.pystone.net/notes/game-graphics-and-runtime/",
      "atlas": "https://www.pystone.net/?node=game-graphics-and-runtime#knowledge-atlas",
      "label": "游戏图形与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "Unity中的“UPM自定义资源包及相关规范”导航项",
      "citation": "https://www.pystone.net/notes/game-graphics-and-runtime/#unity"
    }
  ],
  "contentMarkdown": "# UPM自定义资源包及相关规范\n> 创建时间：2020/9/22 17:06\n\n## UPM自定义资源包及相关规范\n\nByPrin@UWA\n\n  * UPM自定义资源包及相关规范\n    * UPM资源包介绍\n      * 文件布局\n      * Package manifest\n        * Name\n        * Display Name\n        * 版本号规范\n        * the lowest Unity version\n        * Package manifest example\n      * Assembly definition\n      * LICENSE相关（暂时忽略）\n    * 步骤\n      * 1\\. 按照规范创建Package\n      * 分发\n        * zip\n        * Git代码库分发\n    * README文档\n    * Changelog规范\n    * Semantic Versioning规范\n    * Ref\n\n## UPM资源包介绍\n\n作用：给Unity Package Manager制作自定义资源包，并上传至Github托管。使用PackageManager设定项目的依赖、解析资源包依赖、下载添加需要的资源包，将内容整合到项目中，以便在其他项目中使用，并与其他开发者共享。\n常用于\n\n  * 编辑器工具——文本编辑器、动画查看器或文本框架、Physics API、图形管线\n\n  * 内容库——纹理和动画资源集合\n\n> **Unity 2018.3 及之后版本, Unity Package Manager (UPM) 开始支持 Git**\n\n### 文件布局\n\nUPM资源包是一个按特定标准排列的文件夹，是一个包含各种功能、资源的容器。必须遵循Unity的包格式标准才能正确运行（推荐的文件布局和版本号格式）。\n\n```csharp\nclass Program\n{\n    static void Main(string[] args)\n    {\n        dynamic dyn = 1;\n        object obj = 1;\n        dyn = dyn + 3;\n        //obj = obj + 3; 报错\n\n        // Rest the mouse pointer over dyn and obj to see their\n        // types at compile time.\n        System.Console.WriteLine(dyn.GetType());\n        System.Console.WriteLine(obj.GetType());\n    }\n}\n\n```\n\n> 文件夹名称以~结尾不会显示在Editor的Project窗口\n\n### Package manifest\n\n可以在Unity - Inspector面板填写\n\ncrucial information\n\n  * its registered name\n\n  * version number\nTo User:\n\n  * a user-friendly name that appears in the list view on the Package Manager window.\n\n  * a brief description of the package\n\n  * the earliest version of Unity the package is compatible with.\n\n#### Name\n\nThis name must conform to the Unity Package Manager naming convention, which uses reverse domain name notation.\n\n  * Start with `com.<company-name>.`\n\n  * Contain **only lowercase letters** , digits, hyphens (-), underscores (_), and periods (.)\n\n#### Display Name\n\n是在Package Manager窗口显示给用户的名称，也是在Project窗口显示的包的Root文件夹的名称。\n\n#### 版本号规范\n\nMajor.Minor.Patch\n\n#### the lowest Unity version\n\nIf omitted, the package is considered compatible with all Unity versions.\nA package that is not compatible with Unity will not appear in the Package Manager window.\n\n#### Package manifest example\n\n在包的根目录下创建文件`package.json`，只要格式符合规范，就能被UPM识别\n\n```csharp\nclass Program\n{\n    static void Main(string[] args)\n    {\n        dynamic dyn = 1;\n        object obj = 1;\n        dyn = dyn + 3;\n        //obj = obj + 3; 报错\n\n        // Rest the mouse pointer over dyn and obj to see their\n        // types at compile time.\n        System.Console.WriteLine(dyn.GetType());\n        System.Console.WriteLine(obj.GetType());\n    }\n}\n\n```\n\n### Assembly definition\n\nAssembly definition files are the Unity equivalent to a C# project in the .NET ecosystem. You must set explicit references in the assembly definition file to other assemblies (whether in the same package or in external packages).\n\n命名规则：\nEditor/MyCompany.MyFeature.Editor.asmdef\nRuntime/MyCompany.MyFeature.Runtime.asmdef\n\nCompanyName.FeatureName与package.json文件一致\n文件的名称与文件中的”name”一致\n\n> 使用asmdef的优势\n>\n>   * 更短的编译时间\n>\n>   * 发挥访问修饰符”internal”的作用\n>\n>   * 允许使用 unsafe code\n>\n>   * .dll 文件可以指定特定的程序集引用。\n>\n>\n\n一些注意事项：\n\n  1. Editor 文件夹下的 AssemblyDefinition 中 Platform 只能选择 Editor，并且 Reference 必须添加上 Runtime 中的那个 AssemblyDefiniion\n\n### LICENSE相关（暂时忽略）\n\n推荐添加Third Party Notices.md 和 LICENSE.md\n\n  * LICENSE.md：例如以MIT许可证为准的开源许可证MD文件\n\n## 步骤\n\n### 1\\. 按照规范创建Package\n\n### 分发\n\n#### zip\n\n压缩为zip文件\nUnity Package Manager窗口通过Add Package from Disk添加\n\n#### Git代码库分发\n\n添加到Git仓库中，包括meta文件\n\n下载方式（使用者必须安装git）\n\n  * 在PackageManager中通过Git URL直接下载\n\n```csharp\nclass Program\n{\n    static void Main(string[] args)\n    {\n        dynamic dyn = 1;\n        object obj = 1;\n        dyn = dyn + 3;\n        //obj = obj + 3; 报错\n\n        // Rest the mouse pointer over dyn and obj to see their\n        // types at compile time.\n        System.Console.WriteLine(dyn.GetType());\n        System.Console.WriteLine(obj.GetType());\n    }\n}\n\n```\n\n## README文档\n\nDeveloper package documentation. This is generally documentation to help developers who want to modify the package or push a new change on the package master source repository.\n\n## Changelog规范\n\nYou can update the CHANGELOG.md file every time you publish a new version. Every new feature or bug fix should have a trace in this file.\n\n**Added** for new features.\n**Changed** for changes in existing functionality.\n**Deprecated** for soon-to-be removed features.\n**Removed** for now removed features.\n**Fixed** for any bug fixes.\n**Security** in case of vulnerabilities.\n\n> 轻量级的使用Fixed和Features就足够了\n\n例如：\n\n```csharp\nclass Program\n{\n    static void Main(string[] args)\n    {\n        dynamic dyn = 1;\n        object obj = 1;\n        dyn = dyn + 3;\n        //obj = obj + 3; 报错\n\n        // Rest the mouse pointer over dyn and obj to see their\n        // types at compile time.\n        System.Console.WriteLine(dyn.GetType());\n        System.Console.WriteLine(obj.GetType());\n    }\n}\n\n```\n\n> 原则\n>  Changelogs are for humans, not machines.\n>\n>   * There should be an entry for every single version.\n>\n>   * The same types of changes should be grouped.\n>\n>   * Versions and sections should be linkable.\n>\n>   * The latest version comes first.\n>\n>   * The release date of each version is displayed.\n>\n>   * Mention whether you follow Semantic Versioning.\n>\n>\n\n## Semantic Versioning规范\n\nMAJOR.MINOR.PATCH\n\n  * MAJOR introduces one or more breaking changes\n\n  * MINOR introduces one or more **backward-compatible API changes**\n\n  * PATCH only introduces bug fixes with no API changes at all\n\n> When you begin to develop a package, start the version number at **0.1.0.** The MAJOR version number 0 is reserved for packages in their initial development phase. During initial development, package APIs change often, frequently in a breaking manner, so keep the MAJOR version number at 0 until you consider your package stable enough and ready for use in production.\n\nPS: 该规范主要在开发提供给用户的API时有重要作用。先不深究，大致按照此标准进行即可。\n\n## Ref\n\n<https://docs.unity.cn/2019.4/Documentation/Manual/CustomPackages.html>\n<https://keepachangelog.com/en/1.0.0/>\n<https://semver.org/>\n<https://www.jianshu.com/p/153841d65846>\n"
}
