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 ...
随机推荐
- windows下文件名非法字符
/ \ : * ? " < > | / \如果用作文件名,会产生路径问题.因为绝对路径用 \ ; 相对路径用 / ;
- GetType() 和typeof() 的区别
GetType() 非强类型,支持跨程序集发射,用来支持动态引用, A obja=new A(); Type t=obja.GetType() typeof() 强类型,静态的 Type t=type ...
- [.NET] 打造防“狼”神器 :任务栏篇
@微微一笑:本文标题纯属自娱自乐. 隐藏任务栏效果图: 对比 说起来惭愧,上面这个隐藏任务栏功能,只是完成了我一半的预想.本想是可以选择性的隐藏任务栏上的某个TaskBarButton,但是Win7+ ...
- uva 11922 Permutation Transforme/splay tree
原题链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18902 伸展树的区间翻转剪切... 如下: #include< ...
- Get 和 Post方法的登录
1. Get & Post 1> Get请求直接从服务器拿数据 性能好 效率高 在地址栏会显示所有的参数,从直观上安全性不高 由于Get不提交数据给服务器,因此实际的安全性高 实际应用: ...
- linux之mysqlimport的哪些变态事儿
mysqlimport是MySQL导入数据的工具,高效易用. 但掌握不透彻就会有一些变态事情.mysqlimport --host='laswebapp.mdb.game.yy.com' --port ...
- Xcode真机调试错误之"Please valify your...clock not set"
乍一看错误信息是证书过期,其实是描述证书错乱了. Xcode->Preferences->Account 将选中其中一个描述文件 show in finder,将里面的全都删除.
- 22.I/O特性
IO资源 IO是与外界沟通和控制的通道,fpga提供了丰富的IO和一些实用的特性. 本文简要的将主要的特性摘录下来做设计参考用.具体参数参考handbook. 第一部分:IO特性概述 -----通过软 ...
- Android Paint的使用以及方法介绍(附源码下载)
要绘图,首先得调整画笔,待画笔调整好之后,再将图像绘制到画布上,这样才可以显示在手机屏幕上.Android 中的画笔是 Paint类,Paint 中包含了很多方法对其属性进行设置,主要方法如下: se ...
- c/c++中主线程退出,子线程也会退出
#include <windows.h> #include <process.h> /* _beginthread, _endthread */ #include <io ...