void OnPreprocessTexture() { //return; var importer = (assetImporter as TextureImporter); UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Texture2D)); var labels = new List <string>(AssetDatabase.GetLabels(obj)); if (labels == null || labels.Count == 0) { if (!String.IsNullOrEmpty(importer.userData)) { labels = importer.userData.Split("," [0]).ToList(); AssetDatabase.SetLabels(obj, labels.ToArray()); SetLabelSetingsDirty(); } } foreach (string label in labels) { if (Enum.IsDefined(typeof(TextureModifierType), label)) { TextureModifierType type = (TextureModifierType)Enum.Parse(typeof(TextureModifierType), label); if (effecters.Contains(type)) { effecterType = type; } if (modifiers.Contains(type)) { modifierType = type; } if (outputs.Contains(type)) { outputType = type; } } } if (!String.IsNullOrEmpty(importer.spritePackingTag)) { return; } if (effecterType != TextureModifierType.None || modifierType != TextureModifierType.None || outputType != TextureModifierType.None) { if (!SimpleTextureModifierSettings.ForceSTMSetting) { return; } importer.alphaIsTransparency = false; // importer.compressionQuality = (int)TextureCompressionQuality.Best; if (importer.textureFormat == TextureImporterFormat.Automatic16bit) { importer.textureFormat = TextureImporterFormat.AutomaticTruecolor; } else if (importer.textureFormat == TextureImporterFormat.AutomaticCompressed) { importer.textureFormat = TextureImporterFormat.AutomaticTruecolor; } else if (importer.textureFormat == TextureImporterFormat.RGB16) { importer.textureFormat = TextureImporterFormat.RGB24; } else if (importer.textureFormat == TextureImporterFormat.RGBA16) { importer.textureFormat = TextureImporterFormat.RGBA32; } else if (importer.textureFormat == TextureImporterFormat.ARGB16) { importer.textureFormat = TextureImporterFormat.ARGB32; } } }
void OnPreprocessTexture() { //return; var importer = (assetImporter as TextureImporter); UnityEngine.Object obj=AssetDatabase.LoadAssetAtPath(assetPath,typeof(Texture2D)); var labels=new List<string>(AssetDatabase.GetLabels(obj)); if (labels == null || labels.Count == 0) { if(!String.IsNullOrEmpty(importer.userData)) { labels = importer.userData.Split ("," [0]).ToList (); AssetDatabase.SetLabels(obj,labels.ToArray()); SetLabelSetingsDirty (); } } foreach(string label in labels){ if (Enum.IsDefined(typeof(TextureModifierType), label)) { TextureModifierType type=(TextureModifierType)Enum.Parse(typeof(TextureModifierType),label); if(effecters.Contains(type)){ effecterType=type; } if(modifiers.Contains(type)){ modifierType=type; } if(outputs.Contains(type)){ outputType=type; } } } if (!String.IsNullOrEmpty (importer.spritePackingTag)) return; if(effecterType!=TextureModifierType.None || modifierType!=TextureModifierType.None || outputType!=TextureModifierType.None){ if(!EditorPrefs.GetBool(FORCESTMSETTING, true)) return; importer.alphaIsTransparency=false; // importer.compressionQuality = (int)TextureCompressionQuality.Best; if(importer.textureFormat==TextureImporterFormat.Automatic16bit) importer.textureFormat = TextureImporterFormat.AutomaticTruecolor; else if(importer.textureFormat==TextureImporterFormat.AutomaticCompressed) importer.textureFormat = TextureImporterFormat.AutomaticTruecolor; else if(importer.textureFormat==TextureImporterFormat.RGB16) importer.textureFormat = TextureImporterFormat.RGB24; else if(importer.textureFormat==TextureImporterFormat.RGBA16) importer.textureFormat = TextureImporterFormat.RGBA32; else if(importer.textureFormat==TextureImporterFormat.ARGB16) importer.textureFormat = TextureImporterFormat.ARGB32; } }