private TextureConfig GetTerrainConfig() { var config = new TextureConfig(); config.textureFormat = TextureImporterFormat.AutomaticTruecolor; config.eachPlatform = false; config.maxTextureSize = 512; config.isReadable = false; config.mipmapEnabled = false; return(config); }
private TextureConfig GetPetConfig() { var config = new TextureConfig(); config.textureFormat = TextureImporterFormat.AutomaticCompressed; config.eachPlatform = false; config.maxTextureSize = 512; config.isReadable = false; config.mipmapEnabled = false; return(config); }
public override void SetImporterByConfig(AssetImporter assetImporter, AssetItemConfigBase config) { TextureImporter importer = (TextureImporter)assetImporter; TextureConfig textureConfig = (TextureConfig)config; List <string> setFiledInfoList = new List <string>() { "maxTextureSize", "isReadable", "mipmapEnabled" }; bool dirty = false; foreach (var item in setFiledInfoList) { dirty |= TrySetField(item, config, importer); } if (textureConfig.eachPlatform) { foreach (KeyValuePair <string, BuildTarget> keyValuePair in buildTargets) { var format = textureConfig.GetFormatByTarget(keyValuePair.Value); int maxTextureSize; TextureImporterFormat oldFormat; if (importer.GetPlatformTextureSettings(keyValuePair.Key, out maxTextureSize, out oldFormat) == false || oldFormat != format || maxTextureSize != textureConfig.maxTextureSize) { importer.SetPlatformTextureSettings(keyValuePair.Key, textureConfig.maxTextureSize, format); dirty = true; } } } else { if (textureConfig.textureFormat != importer.textureFormat) { dirty = true; importer.textureFormat = textureConfig.textureFormat; } } if (importer.textureType != TextureImporterType.Default) { importer.textureType = TextureImporterType.Default; dirty = true; } if (dirty) { assetImporter.SaveAndReimport(); } }