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 であることを除き、OnPreprocessModel や OnPostprocessModel と同様に、OnPreprocessSpeedTree と OnPostprocessSpeedTree が 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 | インポートされたアセットと、インポートしようとしているアセットに対してのパスを取得します |
context | The import context. |
GetPostprocessOrder | インポート処理される順番を設定します |
GetVersion | アセットのポストプロセッサーのバージョンを返します |
LogError | コンソールにエラーログを表示します |
LogWarning | コンソールに警告ログを表示します |
OnAssignMaterialModel | ソースマテリアルをフィードします。 |
OnPostprocessAllAssets | 任意の数のアセットのインポートが完了した後に呼び出されます(アセットの進捗バーが最後まで到達したとき) |
OnPostprocessAnimation | This function is called when an AnimationClip has finished importing. |
OnPostprocessAssetbundleNameChanged | アセットが他のアセットバンドルに指定される場合に呼び出されるハンドラー |
OnPostprocessAudio | Add this function to a subclass to get a notification when an audio clip has completed importing. |
OnPostprocessCubemap | Add this function to a subclass to get a notification just before a cubemap texture has completed importing. |
OnPostprocessGameObjectWithAnimatedUserProperties | This function is called when the animation curves for a custom property are finished importing. |
OnPostprocessGameObjectWithUserProperties | インポートファイルで少なくとも 1つのユーザープロパティーがアタッチされた各ゲームオブジェクトに対して呼び出されます。 |
OnPostprocessMaterial | Add this function to a subclass to get a notification when a Material asset has completed importing. |
OnPostprocessMeshHierarchy | This function is called when a new transform hierarchy has finished importing. |
OnPostprocessModel | Add this function to a subclass to get a notification when a model has completed importing. |
OnPostprocessSpeedTree | Add this function to a subclass to get a notification when a SpeedTree asset has completed importing. |
OnPostprocessSprites | Add this function to a subclass to get a notification when an texture of sprite(s) has completed importing. |
OnPostprocessTexture | Add this function to a subclass to get a notification when a texture has completed importing just before. |
OnPreprocessAnimation | Add this function to a subclass to get a notification just before animation from a model (.fbx, .mb file etc.) is imported. |
OnPreprocessAsset | Add this function to a subclass to get a notification just before any Asset is imported. |
OnPreprocessAudio | Add this function to a subclass to get a notification just before an audio clip is being imported. |
OnPreprocessMaterialDescription | Add this function to a subclass to recieve a notification when a material is imported from a Model Importer. |
OnPreprocessModel | Add this function to a subclass to get a notification just before a model (.fbx, .mb file etc.) is imported. |
OnPreprocessSpeedTree | Add this function to a subclass to get a notification just before a SpeedTree asset (.spm file) is imported. |
OnPreprocessTexture | Add this function to a subclass to get a notification just before the texture importer is run. |