我没有这个问题,但可以考虑可能的解决办法。
首先要做的是使用
OnPreprocessTexture
功能而不是
OnPostprocessTexture
. 这将在导入纹理之前对其进行修改。
public class PostprocessImages : AssetPostprocessor
{
void OnPreprocessTexture()
{
TextureImporter textureImporter = (TextureImporter)assetImporter;
textureImporter.npotScale = TextureImporterNPOTScale.None;
textureImporter.mipmapEnabled = false;
}
}
TextureImporter.SaveAndReimport()
在对
Texture
这样统一在做出改变后会重新导入。这可能会解决问题。值得注意的是你需要一种方法来确保
纹理导入器。保存和导入()
纹理导入器。保存和导入()
会触发
OnPreprocessTexture()
. 如果不实现一种方法来确定这一点,您将进入一个永不结束的纹理导入的无限循环。在下面的示例中,我使用了
static
List
static List<TextureImporter> importedTex = new List<TextureImporter>();
void OnPostprocessTexture(Texture2D texture)
{
TextureImporter textureImporter = (TextureImporter)assetImporter;
/*Make sure that SaveAndReimport is called once ONLY foe each TextureImporter
There would be infinite loop if this is not done
*/
if (!importedTex.Contains(textureImporter))
{
textureImporter.npotScale = TextureImporterNPOTScale.None;
importedTex.Add(textureImporter);
textureImporter.SaveAndReimport();
}
}