Unity3d教你如何批量修改贴图导入设置工具脚本.doc_第1页
Unity3d教你如何批量修改贴图导入设置工具脚本.doc_第2页
Unity3d教你如何批量修改贴图导入设置工具脚本.doc_第3页
Unity3d教你如何批量修改贴图导入设置工具脚本.doc_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

这个Unity3D批量修改贴图 导入设置工具脚本十分小巧,但是威力大。特别针对大批量贴图要调整尺寸等等的时候作用尤为明显。在菜单中添加“CustomTexture”的方式来批 量改变所选的贴图导入设置。Unity本身只能一次打开一张图片进行导入设置,目前这个脚本可以批量更改贴图格式,是否开启MipMap,调整纹理最大尺 寸,是否可读等等。 用法是把脚本放在你项目的资源目录的Editor文件夹下。然后选择你要批处理的纹理。到菜单中选择要处理的类型就可以了。 ChangeTextureImportSettings。csforUnity2.x程序代码csharp代码:using UnityEngine;using UnityEditor;/ / Batch Texture import settings modifier./ Modifies all selected textures in the project window and applies the requested modification on the/ textures. Idea was to have the same choices for multiple files as you would have if you open the/ import settings of a single texture. Put this into Assets/Editor and once compiled by Unity you find/ the new functionality in Custom - Texture. Enjoy! :-)/ Based on the great work of benblo in this thread:/ /viewtopic.php?t=16079&start=0&postdays=0&postorder=asc&highlight=textureimporter/ Developed by Martin Schultz, Decane in August 2009/ e-mail: / /public class ChangeTextureImportSettings : ScriptableObject MenuItem (Custom/Texture/Change Texture Format/Auto) static void ChangeTextureFormat_Auto() SelectedChangeTextureFormatSettings(TextureImporterFormat.Automatic); MenuItem (Custom/Texture/Change Texture Format/RGB Compressed DXT1) static void ChangeTextureFormat_RGB_DXT1() SelectedChangeTextureFormatSettings(TextureImporterFormat.DXT1); MenuItem (Custom/Texture/Change Texture Format/RGB Compressed DXT5) static void ChangeTextureFormat_RGB_DXT5() SelectedChangeTextureFormatSettings(TextureImporterFormat.DXT5); MenuItem (Custom/Texture/Change Texture Format/RGB 16 bit) static void ChangeTextureFormat_RGB_16bit() SelectedChangeTextureFormatSettings(TextureImporterFormat.RGB16); MenuItem (Custom/Texture/Change Texture Format/RGB 24 bit) static void ChangeTextureFormat_RGB_24bit() SelectedChangeTextureFormatSettings(TextureImporterFormat.RGB24); MenuItem (Custom/Texture/Change Texture Format/Alpha 8 bit) static void ChangeTextureFormat_Alpha_8bit() SelectedChangeTextureFormatSettings(TextureImporterFormat.Alpha8); MenuItem (Custom/Texture/Change Texture Format/RGBA 16 bit) static void ChangeTextureFormat_RGBA_16bit() SelectedChangeTextureFormatSettings(TextureImporterFormat.ARGB16); MenuItem (Custom/Texture/Change Texture Format/RGBA 32 bit) static void ChangeTextureFormat_RGBA_32bit() SelectedChangeTextureFormatSettings(TextureImporterFormat.ARGB32); / - MenuItem (Custom/Texture/Change Texture Size/Change Max Texture Size/32) static void ChangeTextureSize_32() SelectedChangeMaxTextureSize(32); MenuItem (Custom/Texture/Change Texture Size/Change Max Texture Size/64) static void ChangeTextureSize_64() SelectedChangeMaxTextureSize(64); MenuItem (Custom/Texture/Change Texture Size/Change Max Texture Size/128) static void ChangeTextureSize_128() SelectedChangeMaxTextureSize(128); MenuItem (Custom/Texture/Change Texture Size/Change Max Texture Size/256) static void ChangeTextureSize_256() SelectedChangeMaxTextureSize(256); MenuItem (Custom/Texture/Change Texture Size/Change Max Texture Size/512) static void ChangeTextureSize_512() SelectedChangeMaxTextureSize(512); /Unity3D教程: MenuItem (Custom/Texture/Change Texture Size/Change Max Texture Size/1024) static void ChangeTextureSize_1024() SelectedChangeMaxTextureSize(1024); MenuItem (Custom/Texture/Change Texture Size/Change Max Texture Size/2048) static void ChangeTextureSize_2048() SelectedChangeMaxTextureSize(2048); / - MenuItem (Custom/Texture/Change MipMap/Enable MipMap) static void ChangeMipMap_On() SelectedChangeMimMap(true); MenuItem (Custom/Texture/Change MipMap/Disable MipMap) static void ChangeMipMap_Off() SelectedChangeMimMap(false); / - static void SelectedChangeMimMap(bool enabled) Object textures = GetSelectedTextures(); Selection.objects = new Object0; foreach (Texture2D texture in textures) string path = AssetDatabase.GetAssetPath(texture); TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter; textureImporter.mipmapEnabled = enabled; AssetDatabase.ImportAsset(path); /Unity3D教程手册: static void SelectedChangeMaxTextureSize(int size) Object textures = GetSelectedTextures(); Selection.objects = new Object0; foreach (Texture2D texture in textures) string path = AssetDatabase.GetAssetPath(texture); TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter; textureImporter.maxTextureSize = size; AssetDatabase.ImportAsset(path); static void SelectedChangeTextureFormatSettings(TextureImporterFormat newFormat) Object textures = GetSelectedTextures(); Selection.objects = new Object0; foreach (Texture2D texture in textures) string path = AssetDatabase.GetAssetPath(texture); /Debug.Log(path: + path); TextureImporter textur

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论