原地址:http://blog.csdn.net/asd237241291/article/details/8433548

创文章如需转载请注明:转载自 脱莫柔Unity3D学习之旅  QQ群:【】 本文链接地址: Unity3D 批量图片资源导入设置
复制代码
using UnityEngine;
using System.Collections;
using UnityEditor;
/// <summary>
/// 批量图片资源导入设置
/// 使用说明: 选择需要批量设置的贴图,
/// 单击DuanMenu/Texture Import Settings,
/// 打开窗口后选择对应参数,
/// 点击Set Texture ImportSettings,
/// 稍等片刻,--批量设置成功。
/// </summary> public class TextureImportSetting : EditorWindow { /// <summary>
/// 临时存储int[]
/// </summary>
private int[] IntArray = new int[] { , , , , , , , };
//AnisoLevel
private int AnisoLevel = ;
//Filter Mode
private int FilterModeInt = ;
private string[] FilterModeString = new string[] { "Point", "Bilinear", "Trilinear" };
//Wrap Mode
private int WrapModeInt = ;
private string[] WrapModeString = new string[] { "Repeat", "Clamp" };
//Texture Type
private int TextureTypeInt = ;
private string[] TextureTypeString = new string[] { "Texture", "Normal Map", "GUI", "Refelection", "Cookie", "Lightmap", "Advanced" };
//Max Size
private int MaxSizeInt = ;
private string[] MaxSizeString = new string[] { "", "", "", "", "", "", "", "" };
//Format
private int FormatInt = ;
private string[] FormatString = new string[] { "Compressed", "16 bits", "true color" }; /// <summary>
/// 创建、显示窗体
/// </summary>
[@MenuItem("DuanMenu/Texture Import Settings")]
private static void Init()
{
TextureImportSetting window = (TextureImportSetting)EditorWindow.GetWindow(typeof(TextureImportSetting), true, "TextureImportSetting");
window.Show();
} /// <summary>
/// 显示窗体里面的内容
/// </summary>
private void OnGUI()
{
//AnisoLevel
GUILayout.BeginHorizontal();
GUILayout.Label("Aniso Level ");
AnisoLevel = EditorGUILayout.IntSlider(AnisoLevel, , );
GUILayout.EndHorizontal();
//Filter Mode
FilterModeInt = EditorGUILayout.IntPopup("Filter Mode", FilterModeInt, FilterModeString, IntArray);
//Wrap Mode
WrapModeInt = EditorGUILayout.IntPopup("Wrap Mode", WrapModeInt, WrapModeString, IntArray);
//Texture Type
TextureTypeInt = EditorGUILayout.IntPopup("Texture Type", TextureTypeInt, TextureTypeString, IntArray);
//Max Size
MaxSizeInt = EditorGUILayout.IntPopup("Max Size", MaxSizeInt, MaxSizeString, IntArray);
//Format
FormatInt = EditorGUILayout.IntPopup("Format", FormatInt, FormatString, IntArray);
if (GUILayout.Button("Set Texture ImportSettings"))
LoopSetTexture();
} /// <summary>
/// 获取贴图设置
/// </summary>
public TextureImporter GetTextureSettings(string path)
{
TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
//AnisoLevel
textureImporter.anisoLevel = AnisoLevel;
//Filter Mode
switch (FilterModeInt)
{
case :
textureImporter.filterMode = FilterMode.Point;
break;
case :
textureImporter.filterMode = FilterMode.Bilinear;
break;
case :
textureImporter.filterMode = FilterMode.Trilinear;
break;
}
//Wrap Mode
switch (WrapModeInt)
{
case :
textureImporter.wrapMode = TextureWrapMode.Repeat;
break;
case :
textureImporter.wrapMode = TextureWrapMode.Clamp;
break;
}
//Texture Type
switch (TextureTypeInt)
{
case :
textureImporter.textureType = TextureImporterType.Image;
break;
case :
textureImporter.textureType = TextureImporterType.Bump;
break;
case :
textureImporter.textureType = TextureImporterType.GUI;
break;
case :
textureImporter.textureType = TextureImporterType.Reflection;
break;
case :
textureImporter.textureType = TextureImporterType.Cookie;
break;
case :
textureImporter.textureType = TextureImporterType.Lightmap;
break;
case :
textureImporter.textureType = TextureImporterType.Advanced;
break;
}
//Max Size
switch (MaxSizeInt)
{
case :
textureImporter.maxTextureSize = ;
break;
case :
textureImporter.maxTextureSize = ;
break;
case :
textureImporter.maxTextureSize = ;
break;
case :
textureImporter.maxTextureSize = ;
break;
case :
textureImporter.maxTextureSize = ;
break;
case :
textureImporter.maxTextureSize = ;
break;
case :
textureImporter.maxTextureSize = ;
break;
case :
textureImporter.maxTextureSize = ;
break;
}
//Format
switch (FormatInt)
{
case :
textureImporter.textureFormat = TextureImporterFormat.AutomaticCompressed;
break;
case :
textureImporter.textureFormat = TextureImporterFormat.Automatic16bit;
break;
case :
textureImporter.textureFormat = TextureImporterFormat.AutomaticTruecolor;
break;
}
return textureImporter;
} /// <summary>
/// 循环设置选择的贴图
/// </summary>
private void LoopSetTexture()
{
Object[] textures = GetSelectedTextures();
Selection.objects = new Object[];
foreach (Texture2D texture in textures)
{
string path = AssetDatabase.GetAssetPath(texture);
TextureImporter texImporter = GetTextureSettings(path);
TextureImporterSettings tis = new TextureImporterSettings();
texImporter.ReadTextureSettings(tis);
texImporter.SetTextureSettings(tis);
AssetDatabase.ImportAsset(path);
}
} /// <summary>
/// 获取选择的贴图
/// </summary>
/// <returns></returns>
private Object[] GetSelectedTextures()
{
return Selection.GetFiltered(typeof(Texture2D), SelectionMode.DeepAssets);
}
}
复制代码

Unity3D 批量图片资源导入设置的更多相关文章

  1. Unity3D 中 Generic 动画导入设置和 Root Motion 之间的关系

    2条评论 Unity3D 的 Mecanim 动画系统可以直接复用 3DS MAX 中制作的动画文件中的位移,这个就是通过 applyRootMotion 来达成的,我们只需要在使用 Animator ...

  2. magento产品批量导出导入

    magento产品批量导出导入 博客分类: WP / Joomla! / Magento / Shopify / Drupal / Moodle / Zimbra ExcelMobile配置管理XML ...

  3. ABAP-1-会计凭证批量数据导入本地ACCESS

    公司会计凭证导入ACCESS数据库,需要发送给审计,原先的方案是采用DEPHI开发的功能(调用函数获取会计凭证信息,然后INSERT到ACCESS数据表),运行速度非常慢,业务方要求对该功能进行优化, ...

  4. 图解JanusGraph系列 - 关于JanusGraph图数据批量快速导入的方案和想法(bulk load data)

    大家好,我是洋仔,JanusGraph图解系列文章,实时更新~ 图数据库文章总目录: 整理所有图相关文章,请移步(超链):图数据库系列-文章总目录 源码分析相关可查看github(码文不易,求个sta ...

  5. 网格导入设置 Import settings for Meshes

    原地址:http://game.ceeger.com/Components/FBXImporter-Model.html The Import Settings for a model file wi ...

  6. 开源免费接口管理平台eoLinker AMS开源版 V3.2.0更新,增加批量导出导入接口功能!

    eoLinker是一个免费开源的针对开发人员需求而设计的接口管理工具,通过简单的操作来帮助开发者进行接口文档管理.接口自动化测试.团队协作.数据获取.安全防御监控等功能,降低企业的接口管理成本,提高项 ...

  7. .net开源工作流ccflow从表数据数据源导入设置

    第1节. 关键字 驰骋工作流引擎 流程快速开发平台 workflow ccflow jflow  .net开源工作流 第2节. 从表数据导入设置 1.1.1: 概要说明 在从表的使用中我一般都会用到从 ...

  8. ABAP-2-会计凭证批量数据导入本地ACCESS

    ABAP-1-会计凭证批量数据导入本地ACCESS 上一版本出现问题: A.若TXT数据条目超过800万(大概1.3G),则将TXT导入ACCESS过程不成功,ACCESS数据表为空.(Access单 ...

  9. SQL Server Bulk Insert批量数据导入

    SQL Server的Bulk Insert语句可以将本地或远程的数据文件批量导入到数据库中,速度非常的快.远程文件必须共享才行,文件路径须使用通用约定(UNC)名称,即"\\服务器名或IP ...

随机推荐

  1. 配置《算法 第四版》的Eclipse开发环境

    1. 安装JAVA JAVA网址:http://www.oracle.com/technetwork/java/javase/downloads/index.html 配置环境变量(我把JAVA安装在 ...

  2. 006-python基础-条件判断与循环

    一.条件判断 场景一.用户登陆验证 # 提示输入用户名和密码 # 验证用户名和密码 # 如果错误,则输出用户名或密码错误 # 如果成功,则输出 欢迎,XXX! #!/usr/bin/env pytho ...

  3. python 字符串格式化 (%操作符)

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 在许多编程语言中都包含有格式化字符串的功能,比如C和Fortran语言中的格式化输 ...

  4. Python学习教程(learning Python)--3.1 Python的if分支语句

    本节研究一下if分支语句. if分支语句是Python下逻辑条件控制语句,用于条件执行某些语句的控制操作,当if后的条件conditon满足时,if其下的语句块被执行,但当if的控制条件condito ...

  5. angularjs2 学习笔记(二) 组件

    angular2 组件 首先了解angular2 组件的含义 angular2的应用就是一系列组件的集合 我们需要创建可复用的组件供多个组件重复使用 组件是嵌套的,实际应用中组件是相互嵌套使用的 组件 ...

  6. hdu 4613 Points<计算几何>

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4613 题意: 判断一个集合中的点能不能由另一个集合中的点,通过平移,旋转,放缩得到~ 思路:先求出集合中的 ...

  7. oracle - redo 损坏或删除处理方法

    OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - ...

  8. ORACLE 分区表简介

    参考链接:http://blog.csdn.net/ziwen00/article/details/9158725ORACLE-分区表 此文从以下几个方面来整理关于分区表的概念及操作: 1.表空间及分 ...

  9. Virtual Box + CentOS Minimal + Apache搭建Web服务器

    本文并不介绍关于Virtual Box, CentOS, Apache的安装, 主要针对安装后相关的配置, 使宿主机(Host)可以访问客户机(Guest: CentOS in Virtual Box ...

  10. hdu 4324 Triangle LOVE

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4324 Triangle LOVE Description Recently, scientists f ...