原地址: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. 关于frameset中指定区域回退的实现

    指定区域(Frame)的回退,网上大都写的是用  window.parent.window.mainFrame.rightFrame.history.back();来进行回退,但是我这边就是不行,一直 ...

  2. [转]浅谈Python web框架

    说到web framework,Ruby的世界Rails一统江湖,而Python则是一个百花齐放的世界,各种micro-framework.framework不可胜数,不完全列表见:http://wi ...

  3. TeXworks代码补全功能

    使用Tab键会自动补全(实在是太TM的方便了) 比如:

  4. hdu 1867 A + B for you again

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1867 A + B for you again Description Generally speaki ...

  5. android 下滤镜效果的实现

    android 下滤镜效果的实现 滤镜过滤颜色已实现,简单版本可通过下面代码的3个参数实现黑白.红.绿...等7种过滤(RGB的7种组合). 理论上讲可以过滤为任意颜色.调整混合结果的比值就行了. p ...

  6. [转]Ubuntu 12.04开机自动挂载Windows分区

    [转]Ubuntu 12.04开机自动挂载Windows分区 http://www.cnblogs.com/A-Song/archive/2013/02/27/2935255.html 系统版本:Ub ...

  7. 12.Warning (15714): Some pins have incomplete I/O assignments. Refer to the I/O Assignment Warnings report for details

    解释:对于一些管脚,缺少了部分描述,需要再添加一些设置,比如current strength,slew rate等: 措施:打开pin plannel界面,在current strength和slew ...

  8. 与电子钱包相关的APDU指令

    CLS:命令报文的类别字节,class byte(类别字节) of command message(命令报文) UranusPay ED/EP: UranusPay是HB公司开发的COS,而ED是电子 ...

  9. win8中如何禁用屏幕旋转的快捷键

    程序员通常会使用ctrl+alt+方向键 里编辑代码,特别对于使用eclipse的程序员,更是如此,但是win8却把这一快捷键给占用了,很不爽,如何办,很简单.直接上图: 2.但是发现禁用之后并没有解 ...

  10. ostream类重载的operator<<()函数

    ostream类重载了operator<<()以识别不同的类型,如: int short  long unsigned int unsigned short unsigned long f ...