自定义Unity Package Manager(UPM)

官方文档

https://docs.unity3d.com/Manual/CustomPackages.html

按照官方文档可以很顺利的开发自对应的package,但对于package.json的建立、Sample的搭建过程中有一些值得注意的地方,记录在此,以做回顾。目前使用的是GIT方式添加package的方式。

1、不需要网上教程说的一定要建立Editor、Runtime文件夹,只需要按照自己的规划即可。但区分文件夹,更标准。也验证了自己的代码更规范。

2、package.json较完整的示例如下,部分字段的作用如图所示,可按需删除非必须的字段。

{
  "name": "com.[company-name].[package-name]",
  "version": "1.2.3",
  "//displayName说明":"图中1区域",
  "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": "[email protected]",
    "url": "https://www.unity3d.com"
  },
  "samples": [
        {
           "//displayName说明":"图中2区域",
           "displayName": "HDRP Shaders",
            "description": "Contains sample shaders for the High Definition render pipeline",
            "//path说明":"文件夹一定是Samples~,要带~结束,才不会被package直接包含在内",
            "path": "Samples~/SamplesHDRP"
        },
        {
            "displayName": "URP Shaders",
            "description": "Contains sample shaders for the Universal render pipeline",
            "path": "Samples~/SamplesUniversalRP"
        },
        {
            "displayName": "Standard RP Shaders",
            "description": "Contains sample shaders for the Standard render pipeline",
            "path": "Samples~/SamplesStandard"
        }
    ]
}
示例图

3、导入Packages中的Samples 会按照Package displayName/Version/Samples Displayname存放在Asset目录下。

4、特别注意samples的path 一定要在“Samples~”目录下。

你可能感兴趣的:(自定义Unity Package Manager(UPM))