Version: 2021.3
言語: 日本語

AssetPostprocessor

class in UnityEditor

マニュアルに切り替える

説明

AssetPostprocessor を利用すると、インポートしたパイプラインをフックし、アセットをインポートする前と後にスクリプトを実行することが可能になります。

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. アニメーション生成が以前に無効にされていなければ (ModelImporter.generateAnimations 参照)、スキンメッシュとアニメーションが生成されます。可能な場合は、アバターも作成され、ゲームオブジェクトのヒエラルキーが最適化されます。その後、OnPostprocessModel がルートのゲームオブジェクトのために呼び出されます。 assetImporter のタイプが SpeedTreeImporter であることを除き、OnPreprocessModelOnPostprocessModel と同様に、OnPreprocessSpeedTreeOnPostprocessSpeedTree が SpeedTree アセット (.spm file) に関して呼び出されます。

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.

変数

assetImporterインポートしようとしている AssetImporter を参照します
assetPathインポートされたアセットと、インポートしようとしているアセットに対してのパスを取得します
contextThe import context.

Public 関数

GetPostprocessOrderインポート処理される順番を設定します
GetVersionアセットのポストプロセッサーのバージョンを返します
LogErrorコンソールにエラーログを表示します
LogWarningコンソールに警告ログを表示します

メッセージ

OnAssignMaterialModelソースマテリアルをフィードします。
OnPostprocessAllAssets任意の数のアセットのインポートが完了した後に呼び出されます(アセットの進捗バーが最後まで到達したとき)
OnPostprocessAnimationThis function is called when an AnimationClip has finished importing.
OnPostprocessAssetbundleNameChangedアセットが他のアセットバンドルに指定される場合に呼び出されるハンドラー
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.
OnPostprocessGameObjectWithUserPropertiesインポートファイルで少なくとも 1つのユーザープロパティーがアタッチされた各ゲームオブジェクトに対して呼び出されます。
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.
OnPostprocessPrefabGets a notification when a Prefab completes 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 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.
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.
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.
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.