In Package Manager UI 2.0 (compatible with Unity 2019.1), you can include samples in a package.
A sample could be a piece of example code, or some beginner assets that can be optionally brought into the user’s project under the Assets
folder.
In the future, the editor will expose packaging functionality to properly expose samples, but in the meantime, here’s is an example on how samples can be manually configured to be recognized in the Package Manager UI.
First, make sure to place your samples under the Samples~
folder.
<Root>
├── package.json
├── Samples~
│ ├── Sample Folder 1
│ │ └── …
│ └── Sample Folder 2
│ └── …
└── ...
Then you need to specify them in the package.json
file. Note that each sample needs to point to a directory.
{
"samples": [
{
"displayName": "Sample Name 1",
"description": "Description for sample 1",
"path": "Samples~/Sample Folder 1"
},
{
"displayName": "Sample Name 2",
"description": "Description for sample 2",
"path": "Samples~/Sample Folder 2"
}
]
}
Then you’ll be able to see the import buttons in Package Manager UI as shown below.
When the user chooses to import a sample, samples will be copied to the project’s Assets/Samples/Package Name/Version/Sample Name
directory, thus allowing it to be modified.