Unity3D批量修改Texture属性
来源:互联网 发布:小猪微信cms使用教程 编辑:程序博客网 时间:2024/05/22 11:58
Unity3D批量修改Texture属性
- Unity3D批量修改Texture属性
- 功能
- 思路
- 代码
功能
批量读取选择的文件夹下的Texture类型文件,按照需求更改Texture的属性。
思路
读取所选择文件夹下的某类型文件,包括所有子文件夹,有一个很强大的函数。
public static Object[] GetFiltered(Type type, SelectionMode mode);
其中SelectionMode可选择如下:
只要设置为DeepAssets ,就可递归读取所有子文件夹。
代码
思路很简单,直接放代码。
public class SetTextureInfo : EditorWindow{ /// <summary> /// 循环设置选择的图片 /// </summary> [MenuItem("SetTextureInfo/SetTextureInfo")] private static void LoopSetTexture() { Object[] textures = Selection.GetFiltered(typeof(Texture2D), SelectionMode.DeepAssets); foreach (Texture2D texture in textures) { string path = AssetDatabase.GetAssetPath(texture); TextureImporter texImporter = AssetImporter.GetAtPath(path) as TextureImporter; //不处理类型为“Lightmap”的Texture if ("Lightmap" != texImporter.textureType.ToString()) { //修改Texture Type texImporter.textureType = TextureImporterType.Advanced; //修改Aniso Level texImporter.anisoLevel = 0; //修改Read/Write enabled texImporter.isReadable = false; //修改Generate Mip Maps texImporter.mipmapEnabled = false; string texName = texture.name; int maxSize[2]; TextureImporterFormat texFormat; texImporter.GetPlatformTextureSettings("Android", out maxSize[0], out texFormat); texImporter.GetPlatformTextureSettings("iPhone", out maxSize[1], out texFormat); if (texName.Contains("alpha")) { texImporter.SetPlatformTextureSettings("Android", maxSize[0], TextureImporterFormat.ETC2_RGBA8); texImporter.SetPlatformTextureSettings("iPhone", maxSize[1], TextureImporterFormat.PVRTC_RGBA4); } else { texImporter.SetPlatformTextureSettings("Android", maxSize[0], TextureImporterFormat.ETC2_RGB4); texImporter.SetPlatformTextureSettings("iPhone", maxSize[1], TextureImporterFormat.PVRTC_RGB4); } AssetDatabase.ImportAsset(path); } } }}
0 0
- Unity3D批量修改Texture属性
- unity3d 批量修改Texture属性 两种方式加载贴图
- Unity3D批量修改纹理
- 批量修改Texture属性 两种方式加载贴图,通过Resources.LoadAll Directoy 获取项目路径:Application.dataPath; using UnityEn
- 批量修改控件属性
- 批量修改文件夹属性
- Unity3d 批量修改纹理格式
- unity使用代码修改Texture属性,一键生成精灵
- Unity 使用代码修改Texture属性 一键生成精灵
- 文件夹属性批量修改工具
- 动态批量修改字段属性
- 动态批量修改字段属性
- 动态批量修改字段属性
- c#批量修改控件属性
- Altium Designer 批量修改属性
- 批量修改AD用户属性
- 织梦批量修改属性
- Unity3D Texture to Sprite
- redis配置认证密码
- Maven仓库(四)
- 我的第一篇博客
- Hibernate常用方法之get
- VisualSVN Server:Custom action GenerateSSLKey failed: Command terminated with non-zero exit code
- Unity3D批量修改Texture属性
- Maven的生命周期和插件(五)
- 隐写分析笔记(1)
- 删除文件中以xxx开头的行
- Hadoop 格式化namenode错误:FATAL namenode.NameNode: Exception innamenode join
- memcached的安装
- 那些年遇见的最逗得老师
- 自动滑动的Scrollview
- android4.0 HttpClient 以后不能在主线程发起网络请求