Version: 2020.3

AssetPostprocessor.OnPreprocessAsset()

切换到手册

描述

将此函数添加到一个子类中,以在导入所有资源之前获取通知。

借助此函数,您可以通过代码控制导入设置。

using UnityEditor;

class MyModelPostprocessor : AssetPostprocessor { void OnPreprocessAsset() { if (assetImporter.importSettingsMissing) { ModelImporter modelImporter = assetImporter as ModelImporter; if (modelImporter != null) { if (!assetPath.Contains("@")) modelImporter.importAnimation = false; modelImporter.materialImportMode = ModelImporterMaterialImportMode.None; } } } }