赞
踩
编辑器下批量模型贴图的Generate Mip Maps的勾选状态
public static void ModelDisableGenerateMipMaps() { FileInfo[] fs = new DirectoryInfo(prefabPath).GetFiles("*.prefab", SearchOption.AllDirectories); // Assets/xxx 路径形式 string modelPath = "Assets" + prefabPath.Replace(Application.dataPath, ""); for (int i = 0; i < fs.Length; i++) { FileInfo f = fs[i]; string absFilePath = modelPath + f.Name; GameObject temp = AssetDatabase.LoadAssetAtPath<GameObject>(absFilePath); MeshRenderer meshRenderer = temp.GetComponent<MeshRenderer>(); if (meshRenderer) { Material material = meshRenderer.sharedMaterial; string imgPath = AssetDatabase.GetAssetPath(material.mainTexture); // Debug.Log(imgPath); TextureImporter textureImporter = TextureImporter.GetAtPath(imgPath) as TextureImporter; if (textureImporter.mipmapEnabled) { textureImporter.mipmapEnabled = false; textureImporter.SaveAndReimport(); AssetDatabase.Refresh(); } } else { Debug.LogError("不存在meshRenderer:" + f.Name); } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。