マップ操作のインポート:マップMaxSizeとFormatの処理
2714 ワード
using UnityEngine;
using System.Collections;
using UnityEditor;
public class ImportModflyTextures : AssetPostprocessor{
private uint m_Version = 0;
public override uint GetVersion() {return m_Version;}
public void OnPostprocessTexture(Texture2D tex){
TextureImporter importerTexture = (TextureImporter)assetImporter;
if(importerTexture.DoesSourceTextureHaveAlpha() == true){
if(tex.width >= tex.height )
importerTexture.maxTextureSize = tex.width/2;
else importerTexture.maxTextureSize = tex.height/2;
importerTexture.textureFormat = TextureImporterFormat.AutomaticTruecolor;
}else{
if(tex.width >= tex.height )
importerTexture.maxTextureSize = tex.width;
else importerTexture.maxTextureSize = tex.height;
importerTexture.textureFormat = TextureImporterFormat.AutomaticCompressed;
}
//AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
}
}