static void ChangeAniso(int newLevel, Platform somePlatform = Platform.Default)
 {
     Debug.Log(System.String.Format("{0} Set AnisoLevel '{2}' @ {1} platform", logTitle, somePlatform, newLevel));
     TextureImportParams tiParams = new TextureImportParams(Actions.SetAniso, somePlatform);
     tiParams.anisoLevel = newLevel;
     SelectedChangeAnyPlatformSettings(tiParams);
 }
    /// <summary>
    /// Main work method
    /// </summary>
    static void SelectedChangeAnyPlatformSettings(TextureImportParams tip)
    {
        int processingTexturesNumber;
        Object[] originalSelection = Selection.objects;
        Object[] textures = GetSelectedTextures();
        Selection.objects = new Object[0]; //Clear selection (for correct data representation on GUI)
        processingTexturesNumber = textures.Length;
        if (processingTexturesNumber == 0)
        {
            Debug.LogWarning(logTitle + "Nothing to do. Please select objects/folders with 2d textures in Project tab");
            return;
        }
        AssetDatabase.StartAssetEditing();
        foreach (Texture2D texture in textures)
        {
            string path = AssetDatabase.GetAssetPath(texture);
            TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
            switch (tip.action)
            {
                //platform independent
                case Actions.SetMipMap:
                    textureImporter.mipmapEnabled = tip.mipMap;
                    break;
                case Actions.SetReadWrite:
                    textureImporter.isReadable = tip.readWriteMode;
                    break;
                case Actions.SetWrapMode:
                    textureImporter.wrapMode = tip.wrapMode;
                    break;
                case Actions.SetFilterMode:
                    textureImporter.filterMode = tip.filterMode;
                    break;
                case Actions.SetAniso:
                    textureImporter.anisoLevel = tip.anisoLevel;
                    break;
                case Actions.SetAll: //Set all platform independent settings
                    textureImporter.textureType = TextureImporterType.Advanced;
                    textureImporter.mipmapEnabled = tip.mipMap;
                    textureImporter.isReadable = tip.readWriteMode;
                    textureImporter.wrapMode = tip.wrapMode;
                    textureImporter.filterMode = tip.filterMode;
                    textureImporter.anisoLevel = tip.anisoLevel;
                    textureImporter.maxTextureSize = tip.maxSize;
                    textureImporter.textureFormat = tip.tiFormat;
                    break;
                //platform specific props
                default:
                    if (tip.platform == Platform.Default) //default platform mode
                    {
                        switch (tip.action)
                        {
                            case Actions.SetMaxTextureSize:
                                textureImporter.maxTextureSize = tip.maxSize;
                                break;
                            case Actions.SetTextureFormat:
                                textureImporter.textureFormat = tip.tiFormat;
                                break;
                            default:
                                Debug.Log("Unhandled action on Platform.Default: " + tip.action); //foolproof
                                return;
                        }
                    }
                    else //override mode
                    {
                        if (tip.platform != Platform.All)
                            textureImporter.GetPlatformTextureSettings(tip.platform.ToString(), out currentMaxTextureSize, out currentTIFormat);

                        switch (tip.action)
                        {
                            case Actions.SetMaxTextureSize:
                                textureImporter.SetPlatformTextureSettings(tip.platform.ToString(), tip.maxSize, currentTIFormat);
                                break;
                            case Actions.SetTextureFormat:
                                textureImporter.SetPlatformTextureSettings(tip.platform.ToString(), currentMaxTextureSize, tip.tiFormat);
                                break;
                            case Actions.ClearOverrides:
                                if (tip.platform == Platform.All)
                                {
                                    ClearPlatformOverrides(Platform.Android.ToString(), textureImporter);
                                    ClearPlatformOverrides(Platform.Standalone.ToString(), textureImporter);
                                    ClearPlatformOverrides(Platform.iPhone.ToString(), textureImporter);
                                    ClearPlatformOverrides(Platform.Web.ToString(), textureImporter);
                                    ClearPlatformOverrides(Platform.FlashPlayer.ToString(), textureImporter);
                                }
                                else
                                    ClearPlatformOverrides(tip.platform.ToString(), textureImporter);
                                break;
                            default:
                                Debug.Log("Unhandled action on Platform." + tip.platform.ToString() + ": " + tip.action); //foolproof
                                return;
                        }
                    }
                    break;
            }
            AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
        }
        AssetDatabase.StopAssetEditing();
        Selection.objects = originalSelection; //Restore selection
        Debug.Log("Textures processed: " + processingTexturesNumber);
    }
 static void ClearOverrides(Platform somePlatform = Platform.All)
 {
     Debug.Log(System.String.Format("{0} Clear overrides @ {1} platform", logTitle, somePlatform));
     TextureImportParams tiParams = new TextureImportParams(Actions.ClearOverrides, somePlatform);
     SelectedChangeAnyPlatformSettings(tiParams);
 }
 static void ChangeWrapMode(TextureWrapMode newMode, Platform somePlatform = Platform.Default)
 {
     Debug.Log(System.String.Format("{0} Set TextureWrapMode '{2}' @ {1} platform", logTitle, somePlatform, newMode));
     TextureImportParams tiParams = new TextureImportParams(Actions.SetWrapMode, somePlatform);
     tiParams.wrapMode = newMode;
     SelectedChangeAnyPlatformSettings(tiParams);
 }
 static void ChangeTextureFormat(TextureImporterFormat newFormat, Platform somePlatform = Platform.Default)
 {
     Debug.Log(System.String.Format("{0} Set TextureImporterFormat '{2}' @ {1} platform", logTitle, somePlatform, newFormat));
     TextureImportParams tiParams = new TextureImportParams(Actions.SetTextureFormat, somePlatform);
     tiParams.tiFormat = newFormat;
     SelectedChangeAnyPlatformSettings(tiParams);
 }
 //--- Work ----------------------------------
 static void ChangeRW(bool flag, Platform somePlatform = Platform.Default)
 {
     Debug.Log(System.String.Format("{0} Set ReadWriteMode '{2}' @ {1} platform", logTitle, somePlatform, flag));
     TextureImportParams tiParams = new TextureImportParams(Actions.SetReadWrite, somePlatform);
     tiParams.readWriteMode = flag;
     SelectedChangeAnyPlatformSettings(tiParams);
 }
 static void ChangeMaxTextureSize(int newSize, Platform somePlatform = Platform.Default)
 {
     Debug.Log(System.String.Format("{0} Set MaxTextureSize '{2}' @ {1} platform", logTitle, somePlatform, newSize));
     TextureImportParams tiParams = new TextureImportParams(Actions.SetMaxTextureSize, somePlatform);
     tiParams.maxSize = newSize;
     SelectedChangeAnyPlatformSettings(tiParams);
 }
 static void SelectedSetDefaults()
 {
     TextureImportParams tiParams = new TextureImportParams(Actions.SetAll, Platform.Default);
     tiParams.anisoLevel = 1;
     tiParams.filterMode = FilterMode.Bilinear;
     tiParams.maxSize = 4096;
     tiParams.mipMap = false;
     tiParams.readWriteMode = true;
     tiParams.tiFormat = TextureImporterFormat.RGBA32;
     tiParams.wrapMode = TextureWrapMode.Clamp;
     Debug.Log(System.String.Format(
       "{0} Set predefined params @ {1} platform: TextureImporterFormat {2}, MaxTextureSize {3}, MipMap {4}, RWMode {5}, FilterMode {6}, AnisoLevel {7}, WrapMode {8}",
       logTitle, tiParams.platform, tiParams.tiFormat, tiParams.maxSize, tiParams.mipMap, tiParams.readWriteMode,
       tiParams.filterMode, tiParams.anisoLevel, tiParams.wrapMode));
     SelectedChangeAnyPlatformSettings(tiParams);
 }