| Parameter | Description |
|---|---|
| extension | The extension of the artifact associated with this data. |
| span | The content data for the artifact. |
Sets the data to be written to the artifact file.
An artifact is part of the result of an importer and can contain any data that isn't a UnityEngine.Object.
Multiple artifact file extensions can be used to create multiple artifact files.
The empty and 'info' artifact extensions are reserved by Unity. An empty extension is used for the main artifact, and 'info' is used for the preview data of the imported main object.
For more information on how artifact files work, refer to Contents of the Asset Database documentation.
See also AssetImportContext.SetOutputArtifactFile for an alternative method to supply data using an existing file.
The following example shows how to add artifact data for a TextureImporter AssetPostprocessor to save the color of the first pixel of the texture inside an artifact file.
using UnityEditor; using UnityEngine; using System.Text;
public class SaveFirstPixelColor : AssetPostprocessor { public override uint GetVersion() { return 1; }
void OnPostprocessTexture(Texture2D texture) { if (assetPath.StartsWith("Assets/")) { var artifactData = Encoding.UTF8.GetBytes($"#{ColorUtility.ToHtmlStringRGBA(texture.GetPixel(0, 0))}"); context.SetOutputArtifactData("firstpixelcolor", artifactData); } } }