Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetOutputArtifactFilePath(string)

Returns the path where to write a new Artifact File with the given fileName.
Read time 1 minuteLast updated 16 days ago

Definition

Warning
Deprecated. GetOutputArtifactFilePath has been deprecated. Use SetOutputArtifactData to write artifact data from memory, or SetOutputArtifactFile to copy artifact data from a file instead.
public string GetOutputArtifactFilePath(string fileName)

Parameters

fileName

Unique identifier to refer to this Artifact File.

Returns

Type

Description

stringThe file path which can be used to create a new Artifact File.

Remarks

An Artifact File is part of the result of an importer and can contain any data that are not UnityEngine.Object. For example the 'info' Artifact File is reserved by Unity and stores the preview data of the imported Main Object.
The following example shows how to add an Artifact File for a TextureImporter AssetPostprocessor to save the color of the first pixel of the texture inside an ArtifactFile. See AssetImportContext.GetArtifactData to see how this information can be used by another importer to depend on this value and not the whole texture.

Examples

using System;using System.IO;using UnityEditor;using UnityEngine;public class SaveFirstPixelColor : AssetPostprocessor{ public override uint GetVersion() { return 1; } void OnPostprocessTexture(Texture2D texture) { if (assetPath.StartsWith("Assets/")) { string path = context.GetOutputArtifactFilePath("firstpixelcolor"); if (!string.IsNullOrEmpty(path)) File.WriteAllText(path, $"#{ColorUtility.ToHtmlStringRGBA(texture.GetPixel(0, 0))}"); } }}