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 Assets
folder.
When 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 Assets
folder.
パッケージにサンプルを加える手順は以下の通りです。
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 the Samples~
folder has one sample.
ノート: チルダ文字 (~
) は、Samples~
フォルダーの内容を無視するよう Unity に指示します。そのようなフォルダーは .meta
ファイルでは追跡されません。
package.json
マニフェストファイルの samples
配列の下に 各サンプルの JSON オブジェクト を加えます。
サンプルアセットは、パッケージの 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
Add a JSON array called samples
to the package.json
file. For each sample, add a JSON object containing at least the displayName
and the path
to the samples folder:
キー | 説明 |
---|---|
displayName |
The name of the sample as it appears in the package details in the Package Manager window. |
description |
サンプルが表す、または含む内容を簡単に説明します。説明はインターフェースには表示されず、ツールチップとしても表示されません。 |
path |
Samples~ フォルダーからサンプルのルートフォルダーへのパスです。 |
For example, using the same structure as the example for Location of sample files, the samples
section looks similar to this:
{
"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"
}
]
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.