图片导入
来源:互联网 发布:台湾妹网络自拍 编辑:程序博客网 时间:2024/05/21 22:26
图片导入
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[] { 0, 1, 2, 3, 4, 5, 6, 7 };//AnisoLevelprivate int AnisoLevel = 1;//Filter Modeprivate int FilterModeInt = 0;private string[] FilterModeString = new string[] { "Point", "Bilinear", "Trilinear" };//Wrap Modeprivate int WrapModeInt = 0;private string[] WrapModeString = new string[] { "Repeat", "Clamp" };//Texture Typeprivate int TextureTypeInt = 0;private string[] TextureTypeString = new string[] { "Texture", "Normal Map", "GUI", "Refelection", "Cookie", "Lightmap", "Advanced" };//Max Sizeprivate int MaxSizeInt = 5;private string[] MaxSizeString = new string[] { "32", "64", "128", "256", "512", "1024", "2048", "4096" };//Formatprivate int FormatInt = 0;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(){//AnisoLevelGUILayout.BeginHorizontal();GUILayout.Label("Aniso Level ");AnisoLevel = EditorGUILayout.IntSlider(AnisoLevel, 0, 9);GUILayout.EndHorizontal();//Filter ModeFilterModeInt = EditorGUILayout.IntPopup("Filter Mode", FilterModeInt, FilterModeString, IntArray);//Wrap ModeWrapModeInt = EditorGUILayout.IntPopup("Wrap Mode", WrapModeInt, WrapModeString, IntArray);//Texture TypeTextureTypeInt = EditorGUILayout.IntPopup("Texture Type", TextureTypeInt, TextureTypeString, IntArray);//Max SizeMaxSizeInt = EditorGUILayout.IntPopup("Max Size", MaxSizeInt, MaxSizeString, IntArray);//FormatFormatInt = 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;//AnisoLeveltextureImporter.anisoLevel = AnisoLevel;//Filter Modeswitch (FilterModeInt){case 0:textureImporter.filterMode = FilterMode.Point;break;case 1:textureImporter.filterMode = FilterMode.Bilinear;break;case 2:textureImporter.filterMode = FilterMode.Trilinear;break;}//Wrap Modeswitch (WrapModeInt){case 0:textureImporter.wrapMode = TextureWrapMode.Repeat;break;case 1:textureImporter.wrapMode = TextureWrapMode.Clamp;break;}//Texture Typeswitch (TextureTypeInt){case 0:textureImporter.textureType = TextureImporterType.Image;break;case 1:textureImporter.textureType = TextureImporterType.Bump;break;case 2:textureImporter.textureType = TextureImporterType.GUI;break;case 3:textureImporter.textureType = TextureImporterType.Reflection;break;case 4:textureImporter.textureType = TextureImporterType.Cookie;break;case 5:textureImporter.textureType = TextureImporterType.Lightmap;break;case 6:textureImporter.textureType = TextureImporterType.Advanced;break;}//Max Size switch (MaxSizeInt){case 0:textureImporter.maxTextureSize = 32;break;case 1:textureImporter.maxTextureSize = 64;break;case 2:textureImporter.maxTextureSize = 128;break;case 3:textureImporter.maxTextureSize = 256;break;case 4:textureImporter.maxTextureSize = 512;break;case 5:textureImporter.maxTextureSize = 1024;break;case 6:textureImporter.maxTextureSize = 2048;break;case 7:textureImporter.maxTextureSize = 4096;break;}//Formatswitch (FormatInt){case 0:textureImporter.textureFormat = TextureImporterFormat.AutomaticCompressed;break;case 1:textureImporter.textureFormat = TextureImporterFormat.Automatic16bit;break;case 2:textureImporter.textureFormat = TextureImporterFormat.AutomaticTruecolor;break;}return textureImporter;}/// <summary>/// 循环设置选择的贴图/// </summary>private void LoopSetTexture(){Object[] textures = GetSelectedTextures();Selection.objects = new Object[0];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);}}
0 0
- 导入图片
- 图片导入
- 图片的导入导出
- SQL中导入图片
- 图片导入工具实现
- flash 导入图片
- sql server 图片导入
- 导入图片的问题
- HTML导入本地图片
- 数据库图片导入
- WebStorm导入图片
- 图片的导入导出
- Unity3D导入图片资源
- Java导入导出图片
- 【Unity&图片】图片自动批导入问题
- 代码导入图片和音乐
- android图片导入防止OOM
- 将图片导入系统相册
- activity从service中获得数据
- ecshop相册实现鼠标滑过小图切换大图功能
- Java for循环里i++位置改变的影响
- 全排列递归算法(C++实现)
- 不使用ajax实现无刷新提交表单实例
- 图片导入
- HDU ACM 5019 Revenge of GCD
- 【c语言】实现可变参数列表
- 百度语音合成 5月12号为止最新版
- ios--网页js调用oc代码+传递参数+避免中文参数乱码的解决方案(实例)
- XML 学习
- 基于共享内存的分布式消息学习笔记
- 如何使用App Store兑换码进行营销
- Leetcode Convert Sorted Array to Binary Search Tree 有序数组转换成二叉搜索树BST