public void ChangeSelectedTextureFormatSettings(Object[] textures, TextureImporterData targetImpoterData) { if (textures == null) { return; } Selection.objects = new Object[0]; foreach (Texture2D texture in textures) { if (!ChangeTextureFormatSettings(texture, targetImpoterData)) { continue; } } }
protected bool ChangeTextureFormatSettings(Texture2D texture, TextureImporterData targetImpoterData, bool isUsingUnityDeaultCompress = true) { if (!texture) { return(false); } try { string path = AssetDatabase.GetAssetPath(texture); TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter; //if(isUsingUnityDeaultCompress) //{ // if (targetImpoterData.PlatformOverrideContences != null) // { // foreach (var item in targetImpoterData.PlatformOverrideContences) // { // UnOverridePlatformTextureSetting(textureImporter, item.Key); // } // } // textureImporter.SaveAndReimport(); //} //return true; textureImporter.isReadable = targetImpoterData.Readable; textureImporter.sRGBTexture = targetImpoterData.sRGBTexture; textureImporter.mipmapEnabled = targetImpoterData.MipmapEnabled; textureImporter.alphaIsTransparency = targetImpoterData.aTranparency; if (targetImpoterData.PlatformOverrideContences != null) { foreach (var item in targetImpoterData.PlatformOverrideContences) { PlatformTextureSetting(textureImporter, item.Key, item.Value, isUsingUnityDeaultCompress); } } textureImporter.SaveAndReimport(); } catch (System.Exception ex) { Debug.LogError(ex.Message); return(false); } return(true); }
public void Initialize() { if (TargetImporterData == null) { TargetImporterData = new TextureImporterData(); } if (QuickSetResolutions == null) { QuickSetResolutions = new List <string>(); } else { QuickSetResolutions.Clear(); } QuickSetResolutions.Add("UIAtlas"); QuickSetResolutions.Add("Charactor"); QuickSetResolutions.Add("OtherModel"); CurrentSelectedQuickSetResolution = "UIAtlas"; OnQuickButtonChanged(); }