AssetPostprocessor.OnPostprocessAllAssets(string[],string[],string[],string[])

Switch to Manual

Description

在完成任意数量的资源导入后(当资源进度条到达末尾时)调用此函数。

This call may occur after a manual reimport, or when you move an asset or a folder of assets to a new location in the Project window. Every string array item contains a file path relative to the Assets folder, under the Project root. importedAssets contains paths of all assets used in the operation. Each consecutive index of movedAssets and movedFromAssetPaths refers to the same asset.

如果对多个单独的资源(而非包含这些资源的文件夹)执行批量操作,则系统会针对每个资源调用一次此函数,且每个单独的资源在各个数组中都是唯一项。

请注意,必须将此函数声明为 /static/,即,如果将其声明为实例函数,将无法正确调用此函数。

GetPostprocessOrder 指定的顺序不影响此函数。

using UnityEngine;
using UnityEditor;

class MyAllPostprocessor : AssetPostprocessor { static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string str in importedAssets) { Debug.Log("Reimported Asset: " + str); } foreach (string str in deletedAssets) { Debug.Log("Deleted Asset: " + str); }

for (int i = 0; i < movedAssets.Length; i++) { Debug.Log("Moved Asset: " + movedAssets[i] + " from: " + movedFromAssetPaths[i]); } } }