[MenuItem("Assets/11111111")]
public static void FindRef()
{
foreach (var obj in Selection.objects)
{
string path = AssetDatabase.GetAssetPath(obj);
Debug.Log(path);
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
if (importer != null)
{
TextureImporterPlatformSettings importPlatformAndroid = importer.GetPlatformTextureSettings("Android");
importPlatformAndroid.overridden = true;
TextureImporterPlatformSettings importPlatformIPHONE = importer.GetPlatformTextureSettings("iPhone");
importPlatformIPHONE.overridden = true;
TextureImporterPlatformSettings importPlatformWindows = importer.GetPlatformTextureSettings("Standalone");
importPlatformWindows.overridden = false;
if (path.Contains("_nomal"))
{
// normal
importPlatformAndroid.format = TextureImporterFormat.ASTC_RGB_4x4;
importPlatformIPHONE.format = TextureImporterFormat.ASTC_RGB_4x4;
}
else if (importer.DoesSourceTextureHaveAlpha())
{
// rgba
importPlatformAndroid.format = TextureImporterFormat.ASTC_RGBA_4x4;
importPlatformIPHONE.format = TextureImporterFormat.ASTC_RGBA_4x4;
}
else
{
// rgb
importPlatformAndroid.format = TextureImporterFormat.ASTC_RGB_4x4;
importPlatformIPHONE.format = TextureImporterFormat.ASTC_RGB_4x4;
}
importer.SetPlatformTextureSettings(importPlatformAndroid);
importer.SetPlatformTextureSettings(importPlatformIPHONE);
importer.SetPlatformTextureSettings(importPlatformWindows);
// 保存设置
AssetDatabase.ImportAsset(path);
}
else
{
Debug.Log("FAIL");
}
}
}
本文介绍了一个Unity脚本,用于批量设置项目中选中的纹理资源的压缩格式。针对不同类型的纹理(如含Alpha通道或Normal Map),该脚本会自动配置Android和iOS平台的压缩格式,并保留Standalone平台的默认设置。

2076

被折叠的 条评论
为什么被折叠?



