语言中文
  • C#

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; } } }

Did you find this page useful? Please give it a rating: