Unity3D 批量图片资源导入设置
原地址: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 批量图片资源导入设置的更多相关文章
- Unity3D 中 Generic 动画导入设置和 Root Motion 之间的关系
2条评论 Unity3D 的 Mecanim 动画系统可以直接复用 3DS MAX 中制作的动画文件中的位移,这个就是通过 applyRootMotion 来达成的,我们只需要在使用 Animator ...
- magento产品批量导出导入
magento产品批量导出导入 博客分类: WP / Joomla! / Magento / Shopify / Drupal / Moodle / Zimbra ExcelMobile配置管理XML ...
- ABAP-1-会计凭证批量数据导入本地ACCESS
公司会计凭证导入ACCESS数据库,需要发送给审计,原先的方案是采用DEPHI开发的功能(调用函数获取会计凭证信息,然后INSERT到ACCESS数据表),运行速度非常慢,业务方要求对该功能进行优化, ...
- 图解JanusGraph系列 - 关于JanusGraph图数据批量快速导入的方案和想法(bulk load data)
大家好,我是洋仔,JanusGraph图解系列文章,实时更新~ 图数据库文章总目录: 整理所有图相关文章,请移步(超链):图数据库系列-文章总目录 源码分析相关可查看github(码文不易,求个sta ...
- 网格导入设置 Import settings for Meshes
原地址:http://game.ceeger.com/Components/FBXImporter-Model.html The Import Settings for a model file wi ...
- 开源免费接口管理平台eoLinker AMS开源版 V3.2.0更新,增加批量导出导入接口功能!
eoLinker是一个免费开源的针对开发人员需求而设计的接口管理工具,通过简单的操作来帮助开发者进行接口文档管理.接口自动化测试.团队协作.数据获取.安全防御监控等功能,降低企业的接口管理成本,提高项 ...
- .net开源工作流ccflow从表数据数据源导入设置
第1节. 关键字 驰骋工作流引擎 流程快速开发平台 workflow ccflow jflow .net开源工作流 第2节. 从表数据导入设置 1.1.1: 概要说明 在从表的使用中我一般都会用到从 ...
- ABAP-2-会计凭证批量数据导入本地ACCESS
ABAP-1-会计凭证批量数据导入本地ACCESS 上一版本出现问题: A.若TXT数据条目超过800万(大概1.3G),则将TXT导入ACCESS过程不成功,ACCESS数据表为空.(Access单 ...
- SQL Server Bulk Insert批量数据导入
SQL Server的Bulk Insert语句可以将本地或远程的数据文件批量导入到数据库中,速度非常的快.远程文件必须共享才行,文件路径须使用通用约定(UNC)名称,即"\\服务器名或IP ...
随机推荐
- jquery.unobtrusive-ajax.js源码阅读
/*! ** Unobtrusive Ajax support library for jQuery ** Copyright (C) Microsoft Corporation. All right ...
- 决策树的基本ID3算法
一 ID3算法的大致思想 基本的ID3算法是通过自顶向下构造决策树来进行学习的.我们首先思考的是树的构造从哪里开始,这就涉及到选择属性进行树的构造了,那么怎样选择属性呢?为了解决这个问题,我们使用统 ...
- EmguCV学习——简单使用
关于EmguCV我就不多说了,是对应于OpenCV的一套net库. 公司是视觉方面的业务,我又不会c++(好想会啊,正在学习中).由于各种需求,自己觉得对c++不是特别感冒,所以选用了net下的ope ...
- WPF Event 在 Command 中的应用初级篇,支持所有Event 展示松耦合设计的全部代码 - 解决TextBoxBase.TextChanged或者TextBox.TextChanged等类似事件绑定问题。
做过WPF开发的人,都知道做MVVM架构,最麻烦的是Event的绑定,因为Event是不能被绑定的,同时现有的条件下,命令是无法替代Event.而在开发过程中无法避免Event事件,这样MVVM的架构 ...
- EOF 与 getchar()
1.EOF EOF是end of file的缩写,表示"文字流"(stream)的结尾.这里的"文字流",可以是文件(file),也可以是标准输入(stdin) ...
- Linux 删除文件后空间不释放磁盘空间
在Linux操作系统下,有个没用的文件占用了400G,于是删除掉. [root@yoon log]# rm -rf messages [root@yoon log]# df -hFilesystem ...
- ORACLE 分区表简介
参考链接:http://blog.csdn.net/ziwen00/article/details/9158725ORACLE-分区表 此文从以下几个方面来整理关于分区表的概念及操作: 1.表空间及分 ...
- ViewPager+Fragment实现滑动显示,且Fragment里面又放Fragment+viewPager
思路:新建一个Activity,且这个Activity要继承FragementActivity,在Activity的布局文件中放入了一个viewPager,为了效果好看,还做了个导航,使得ViewPa ...
- hdu 5281 Senior's Gun
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5281 Senior's Gun Description Xuejiejie is a beautifu ...
- Android之使用HTTP协议的Get/Post方式向服务器提交数据
1.Get方式 方法:通过拼接url在url后添加相应的数据,如:http://172.22.35.112:8080/videonews/GetInfoServlet?title=霍比特人&t ...