Create samples for packages
Include optional samples that help users learn the package and import example content.
Read time 2 minutesLast updated 14 days ago
Starting with Unity Editor version 2019.1, you can add samples to a package. A sample might be a piece of example code, some shaders and textures, some animation, or any other files that you can usually find under the project's folder.
AssetsWhen you open the Package Manager window and select a package containing samples, an Import button appears in the package's details panel for each sample in the package. When you select Import, the Package Manager copies the whole subfolder structure for that sample under the project's folder.
AssetsTo add samples to your package:
-
Put the asset files or example C# code files under the Samples~ folder. You can have more than one sample in a package; each subfolder of thefolder has one sample.
Samples~
Location of sample files
You can add your sample assets under subfolders of the folder of your package. For example, a package with shader samples might look something like this:
Samples~MyPackage ├── package.json └── Samples~ ├── SamplesHDRP │ ├── Textures │ | ├── MossyRock.bmp │ | └── SandyRock.bmp │ └── Shader │ ├── Lit Texture Blend HDRP.ShaderGraph │ └── Lit Vertex Color HDRP.ShaderGraph └── SamplesStandard │ ├── Textures │ | ├── MossyRock.bmp │ | └── SandyRock.bmp │ └── Shader │ ├── StandardTextureBlend.shader │ └── StandardVertexColor.shader └── SamplesUniversalRP ├── Textures | ├── MossyRock.bmp | └── SandyRock.bmp └── Shader ├── Lit Texture Blend URP.ShaderGraph └── Lit Vertex Color URP.ShaderGraph
Include your samples in the manifest
Add a JSON array called to the file. For each sample, add a JSON object containing at least the and the to the samples folder:
samplespackage.jsondisplayNamepathKey | Description |
|---|---|
| The name of the sample as it appears in the package details in the Package Manager window. |
| A brief description of what the sample demonstrates or contains. This is just for the package manifest. The description doesn't appear in the interface, even as a tooltip. |
| The path from the |
For example, using the same structure as the example for Location of sample files, the section looks similar to this:
samples{ "samples": [ { "displayName": "HDRP Shaders", "description": "Contains sample shaders for the High Definition render pipeline", "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" } ]}