首页 > 其他 > 详细

导入贴图操作:处理贴图MaxSize和Format

时间:2014-05-28 21:18:22      阅读:539      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
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);
    }
}
bubuko.com,布布扣

 

导入贴图操作:处理贴图MaxSize和Format,布布扣,bubuko.com

导入贴图操作:处理贴图MaxSize和Format

原文:http://www.cnblogs.com/softimagewht/p/3754716.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!