在完成任意数量的资源导入后(当资源进度条到达末尾时)调用此函数。
此调用可以在手动重新导入后进行,也可以在您将资源或资源文件夹移动到 Project 窗口中的新位置后进行。每个字符串数组项都包含一个相对于 Project 根目录下的 Assets 文件夹的文件路径。importedAssets
包含操作中使用的所有资源的路径。movedAssets
和 movedFromAssetPaths
的每个连续索引引用同一资源。
如果对多个单独的资源(而非包含这些资源的文件夹)执行批量操作,则系统会针对每个资源调用一次此函数,且每个单独的资源在各个数组中都是唯一项。
请注意,必须将此函数声明为 /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]); } } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.