Version: 2022.1

AssetPostprocessor

class in UnityEditor

切换到手册

描述

AssetPostprocessor 允许您挂接到导入管线并在导入资源前后运行脚本。

在模型导入期间,系统将按以下顺序调用函数: OnPreprocessModel 是在最开始时调用的,您可以覆盖在整个模型导入过程中使用的 ModelImporter 设置。 导入网格和材质后,从导入的节点创建游戏对象层级视图。使用 OnPostprocessMeshHierarchy 来更改层级视图。表示导入节点的每个游戏对象都被赋予相应的 MeshFilter、MeshRenderer 和 MeshCollider 组件。向 MeshRenderer 分配材质之前,系统会调用 OnAssignMaterialModel 函数。 在游戏对象初始化 MeshRenderer 之后且存在“userdata”时,系统会调用 OnPostprocessGameObjectWithUserProperties。这发生在生成子游戏对象之前。 如果在先前的阶段中未禁用动画生成(请参阅 ModelImporter.generateAnimations),则会生成带蒙皮的网格和动画。如果可能,系统还会创建化身并优化游戏对象层级。之后,系统将为根游戏对象调用 OnPostprocessModel。 系统会在 SpeedTree 资源(.spm 文件)上调用 OnPreprocessSpeedTreeOnPostprocessSpeedTree,与调用 OnPreprocessModelOnPostprocessModel 的方式相同,区别在于 SpeedTreeImporter 类型是 assetImporter

变量

assetImporter对资源导入器的引用。
assetPath要导入的资源的路径名称。
context导入上下文。

公共函数

GetPostprocessOrder覆盖导入器的处理顺序。
GetVersion返回资源后处理器的版本。
LogError将导入错误消息记录到控制台。
LogWarning将导入警告记录到控制台。

消息

OnAssignMaterialModel提供源材质。
OnPostprocessAllAssets在完成任意数量的资源导入后(当资源进度条到达末尾时)调用此函数。
OnPostprocessAnimation当 AnimationClip 已完成导入时调用此函数。
OnPostprocessAssetbundleNameChanged将资源分配给其他资源捆绑包时调用的处理程序。
OnPostprocessAudio将此函数添加到一个子类中,以在音频剪辑完成导入时获取通知。
OnPostprocessCubemap将此函数添加到一个子类中,以在立方体贴图纹理完成导入之前获取通知。
OnPostprocessGameObjectWithAnimatedUserProperties当自定义属性的动画曲线已完成导入时调用此函数。
OnPostprocessGameObjectWithUserProperties为每个在导入文件中至少附加了一个用户属性的游戏对象调用此函数。
OnPostprocessMaterial将此函数添加到一个子类中,以在材质资源完成导入时获取通知。
OnPostprocessMeshHierarchy当变换层级视图已完成导入时调用此函数。
OnPostprocessModel将此函数添加到一个子类中,以在模型完成导入时获取通知。
OnPostprocessPrefabGets a notification when a Prefab completes importing.
OnPostprocessSpeedTree将此函数添加到一个子类中,以在 SpeedTree 资源完成导入时获取通知。
OnPostprocessSprites将此函数添加到一个子类中,以在精灵的纹理完成导入时获取通知。
OnPostprocessTextureAdd this function to a subclass to get a notification when a texture2D has completed importing just before Unity compresses it.
OnPostprocessTexture2DArrayAdd this function to a subclass to get a notification when a texture2DArray has completed importing just before Unity compresses it.
OnPostprocessTexture3DAdd this function to a subclass to get a notification when a texture3D has completed importing just before Unity compresses it.
OnPreprocessAnimation将此函数添加到一个子类中,以在导入模型(.fbx、.mb 文件等)中的动画之前获取通知。
OnPreprocessAsset将此函数添加到一个子类中,以在导入所有资源之前获取通知。
OnPreprocessAudio将此函数添加到一个子类中,以在导入音频剪辑之前获取通知。
OnPreprocessCameraDescriptionAdd this function to a subclass to recieve a notification when a camera is imported from a Model Importer.
OnPreprocessLightDescriptionAdd this function to a subclass to recieve a notification when a light is imported from a Model Importer.
OnPreprocessMaterialDescription将此函数添加到一个子类中,以在材质从 Model Importer 导入时接收通知。
OnPreprocessModel将此函数添加到一个子类中,以在导入模型(.fbx、.mb 文件等)之前获取通知。
OnPreprocessSpeedTree将此函数添加到一个子类中,以在导入 SpeedTree 资源(.spm 文件)之前获取通知。
OnPreprocessTexture将此函数添加到一个子类中,以在纹理导入器运行之前获取通知。