AssetPostprocessor.OnPreprocessTexture()

切换到手册

描述

将此函数添加到一个子类中,以在纹理导入器运行之前获取通知。

借助此函数,可以设置导入设置的默认值。

如果要更改纹理的压缩格式,请使用此回调。

using UnityEngine;
using UnityEditor;

// Automatically convert any texture file with "_bumpmap" // in its file name into a normal map.

class MyTexturePostprocessor : AssetPostprocessor { void OnPreprocessTexture() { if (assetPath.Contains("_bumpmap")) { TextureImporter textureImporter = (TextureImporter)assetImporter; textureImporter.convertToNormalmap = true; } } }