AssetPostprocessor Manual     Reference     Scripting  
Scripting > Editor Classes > AssetPostprocessor
AssetPostprocessor

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

Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.

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
assetPath

The path name of the asset being imported.

assetImporter

Reference to the asset importer

Functions
LogWarning

Logs an import warning to the console.

LogError

Logs an import error message to the console.

GetVersion

Returns the version of the asset postprocessor.

GetPostprocessOrder

Override the order in which importers are processed.

Messages Sent
OnPreprocessTexture

Add this function in a subclass to get a notification just before the texture importer is run.

OnPostprocessTexture

Add this function in a subclass to get a notification when a texture has completed importing just before

OnPreprocessModel

Add this function in a subclass to get a notification just before a model (.fbx, .mb file etc.) is being imported.

OnPostprocessModel

Add this function in a subclass to get a notification when a model has completed importing

OnPostprocessGameObjectWithUserProperties

Gets called for each GameObject that had at least one userpropery attached to it in the imported file.

OnAssignMaterialModel

Feeds a source material

OnPostprocessAudio

Add this function in a subclass to get a notification when an audio clip has completed importing.

OnPreprocessAudio

Add this function in a subclass to get a notification just before an audio clip is being imported.

OnPostprocessAllAssets

This is called after importing of any number of assets is complete (when the Assets progress bar has reached the end).