[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");
}
}
}