Version: Unity 6.5 Alpha (6000.5)
LanguageEnglish
  • C#

AssetImportContext.SetOutputArtifactData

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public void SetOutputArtifactData(string extension, ReadOnlySpan<System.Byte> span);

Parameters

Parameter Description
extension The extension of the artifact associated with this data.
span The content data for the artifact.

Description

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); } } }