Unity3d: Bulk Modify Map Import Settings tool script

Source: Internet
Author: User
Tags foreach manual int size modify

This unity3d batch modification map Import Settings tool script is very small, but very powerful. Especially for large-volume mapping to adjust the size and so on when the role is particularly obvious. Add "Custom→texture" to the menu to change the selected texture import settings in bulk. Unity itself can only open a picture at a time to import settings, the current script can change the map format, whether to open mipmap, adjust the maximum size of the texture, readable and so on.

The usage is to put the script under the Editor folder of your project's resource directory. Then select the texture you want to batch. Select the type you want to work with in the menu.

Changetextureimportsettings. csforunity2.x

Program Code CSHARP Code:

Using Unityengine;  
       
Using Unityeditor;  // /////////////////////////////////////////////////////////////////////////////////////////////////////////  
//  
//  
Batch texture import Settings modifier. Modifies all selected textures in the project windows and applies the requested modification on the//textures. Idea is to have the same choices for multiple files as you would have if your open the//import settings of a single Te Xture. Put to Assets/editor and once compiled by Unity your find//The new functionality in Custom-> texture. enjoy! :-)///Based on the great work of Benblo into this thread://Http://forum.unity3d.com/viewtopic.php?t=16079&st Art=0&postdays=0&postorder=asc&highlight=textureimporter////developed by Martin Schultz, Decane in Augu St 2009//E-mail:ms@decane.net///////////////////////////////////////////////////////////////////////////////// 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 Changetextu  
    Reformat_rgb_dxt1 () {selectedchangetextureformatsettings (TEXTUREIMPORTERFORMAT.DXT1); [MenuItem ("Custom/texture/change Texture Format/rgb Compressed DXT5")] static void Changetexturefor  
    Mat_rgb_dxt5 () {selectedchangetextureformatsettings (TEXTUREIMPORTERFORMAT.DXT5); [MenuItem ("Custom/texture/change texture Format/rgb bit")] static void changetextureformat_rgb_1  
    6bit () {selectedchangetextureformatsettings (TEXTUREIMPORTERFORMAT.RGB16); [MenuItem ("Custom/texture/change texture Format/rgb bit")] static void CHangetextureformat_rgb_24bit () {selectedchangetextureformatsettings (textureimporterformat.rgb24); [MenuItem ("Custom/texture/change Texture Format/alpha 8 bit")] static void Changetextureformat_alph  
    A_8bit () {selectedchangetextureformatsettings (TEXTUREIMPORTERFORMAT.ALPHA8); [MenuItem ("Custom/texture/change texture Format/rgba bit")] static void Changetextureformat_rgba  
    _16bit () {selectedchangetextureformatsettings (TEXTUREIMPORTERFORMAT.ARGB16); [MenuItem ("Custom/texture/change texture Format/rgba 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 Changetextu  
    Resize_64 () {selectedchangemaxtexturesize (64); [MenuItem ("custom/texture/change texture size/change Max Texture size/128")] static void Changetext  
    uresize_128 () {selectedchangemaxtexturesize (128); [MenuItem ("custom/texture/change texture size/change Max Texture size/256")] static void Changetext  
    uresize_256 () {selectedchangemaxtexturesize (256); [MenuItem ("custom/texture/change texture size/change Max Texture size/512")] static void Changetext  
    uresize_512 () {selectedchangemaxtexturesize (512); //unity3d Tutorial Manual: www.unitymanual.com [MenuItem ("custom/texture/change texture size/change Max Texture size/102 4 ")]" static void changetexturesize_1024 () {selectedchangemaxtextuReSize (1024); [MenuItem ("custom/texture/change texture size/change Max Texture size/2048")] static void Changetex  
    turesize_2048 () {selectedchangemaxtexturesize (2048); //----------------------------------------------------------------------------//View more highlights in this column: http:// www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/[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 Object[0]; foreach (Texture2d texture In textures) {string path = Assetdatabase.getassetpath (texture);  
            Textureimporter textureimporter = Assetimporter.getatpath (path) as Textureimporter;      
            textureimporter.mipmapenabled = enabled;  
        Assetdatabase.importasset (path);  
       
        }//unity3d Tutorial Manual: www.unitymanual.com static void selectedchangemaxtexturesize (int size) {  
        object[] Textures = getselectedtextures ();  
        Selection.objects = new Object[0];  
            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 Object[0];  
            foreach (texture2d texture in textures) {string path = Assetdatabase.getassetpath (texture);  
            Debug.Log ("Path:" + path);  
            Textureimporter textureimporter = Assetimporter.getatpath (path) as Textureimporter;    
            Textureimporter.textureformat = Newformat;  
        Assetdatabase.importasset (path); } static object[] Getselectedtextures () {return selection.getfiltered (typeof Textur  
    e2d), selectionmode.deepassets); }  
}

Author: csdn Blog Unity3d Learner

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.