Version: 2022.3
言語: 日本語
public string GetOutputArtifactFilePath (string fileName);

パラメーター

fileName Unique identifier to refer to this Artifact File.

戻り値

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

説明

Returns the path where to write a new Artifact File with the given fileName.

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.GetArtifactFilePath to see how this information can be used by another importer to depends on this value and not the whole texture.

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))}"); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961