AssetPostprocessor

class in UnityEditor

Switch to Manual

Description

AssetPostprocessor lets you hook into the import pipeline and run scripts prior or after importing assets.

During model import the functions are called in the the following order:
- OnPreprocessModel is called at the very beginning and you can override ModelImporter settings that are used for the whole model import process.
- After Meshes and Materials are imported, the GameObjects hierarchy is created from the imported nodes. Use OnPostprocessMeshHierarchy to change the hierarchy. Every GameObject that represents an imported node is given a corresponding MeshFilter, MeshRenderer, and MeshCollider component. Before assigning a Material to the MeshRenderer, the OnAssignMaterialModel function is invoked.
- After GameObject has initialized MeshRenderers and "userdata" exists OnPostprocessGameObjectWithUserProperties is called. That happens before children GameObjects are generated.
- If animation generation was not disabled at previous stages (see ModelImporter.generateAnimations), then SkinnedMesh and Animations are generated. If possible Avatar is also created and GameObjecs hierarchy is optimized. After that OnPostprocessModel is called for the root GameObject.

OnPreprocessSpeedTree and OnPostprocessSpeedTree are called on SpeedTree assets (.spm file) the same way as OnPreprocessModel and OnPostprocessModel, except that the assetImporter type is SpeedTreeImporter.

In a production pipeline AssetPostprocessors should always be placed in pre-built dll's in the project instead of in scripts. AssetPostprocessors change the output of imported assets, thus a compile error in one of the scripts will lead to assets being imported differently. This can be a severe issue when working in a production pipeline. By using dll's for AssetPostprocessors you ensure that they can always be executed even if the scripts have compile errors. This way you can override default values in the import settings or modify the imported data like textures or meshes.

Variables

assetImporterReference to the asset importer.
assetPathThe path name of the asset being imported.
contextThe import context.

Public Functions

GetPostprocessOrderПереопределение порядка, в котором обрабатываются импортеры.
GetVersionВозвращает версию постпроцессора ассета.
LogErrorРегистрирует в консоли сообщение об ошибке импорта.
LogWarningРегистрирует в консоли предупреждение импорта.

Messages

OnAssignMaterialModelПодает исходный материал.
OnPostprocessAllAssetsThis is called after importing of any number of assets is complete (when the Assets progress bar has reached the end).
OnPostprocessAnimationThis function is called when an AnimationClip has finished importing.
OnPostprocessAssetbundleNameChangedHandler called when asset is assigned to a different asset bundle.
OnPostprocessAudioAdd this function to a subclass to get a notification when an audio clip has completed importing.
OnPostprocessCubemapAdd this function to a subclass to get a notification just before a cubemap texture has completed importing.
OnPostprocessGameObjectWithAnimatedUserPropertiesThis function is called when the animation curves for a custom property are finished importing.
OnPostprocessGameObjectWithUserPropertiesGets called for each GameObject that had at least one user property attached to it in the imported file.
OnPostprocessMaterialAdd this function to a subclass to get a notification when a Material asset has completed importing.
OnPostprocessMeshHierarchyThis function is called when a new transform hierarchy has finished importing.
OnPostprocessModelAdd this function to a subclass to get a notification when a model has completed importing.
OnPostprocessSpeedTreeAdd this function to a subclass to get a notification when a SpeedTree asset has completed importing.
OnPostprocessSpritesAdd this function to a subclass to get a notification when an texture of sprite(s) has completed importing.
OnPostprocessTextureAdd this function to a subclass to get a notification when a texture has completed importing just before.
OnPreprocessAnimationAdd this function to a subclass to get a notification just before animation from a model (.fbx, .mb file etc.) is imported.
OnPreprocessAssetAdd this function to a subclass to get a notification just before any Asset is imported.
OnPreprocessAudioAdd this function to a subclass to get a notification just before an audio clip is being imported.
OnPreprocessMaterialDescriptionAdd this function to a subclass to recieve a notification when a material is imported from a Model Importer.
OnPreprocessModelAdd this function to a subclass to get a notification just before a model (.fbx, .mb file etc.) is imported.
OnPreprocessSpeedTreeAdd this function to a subclass to get a notification just before a SpeedTree asset (.spm file) is imported.
OnPreprocessTextureAdd this function to a subclass to get a notification just before the texture importer is run.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961