- Home /
SetPlatformTextureSettings: Selected texture format 'Unsupported' for platform 'iPhone'
Why do I get this error:
Selected texture format 'Unsupported' for platform 'iPhone' is not valid with the current texture type 'Sprite'.
When I use this code to auto set my texture import settings?
static void OptimizeFor_iPhone(string path) {
var texture_importer = AssetImporter.GetAtPath(path) as TextureImporter;
var platform_import_settings = texture_importer.GetPlatformTextureSettings("iPhone");
platform_import_settings.maxTextureSize = Mathf.Min(texture_importer.maxTextureSize, platform_import_settings.maxTextureSize);
platform_import_settings.format = TextureImporterFormat.ASTC_RGB_6x6;
platform_import_settings.overridden = true;
// Callstack from error says it comes from this line:
texture_importer.SetPlatformTextureSettings(platform_import_settings);
AssetDatabase.WriteImportSettingsIfDirty(path);
}
(That code is run on the results of AssetDatabase.FindAssets("t:texture ", folders)
to optimize texture settings on a folder.)
It looks like the code successfully changes the import settings (a section with "buildTarget: iPhone" and "textureFormat: 56" is added to the png's .meta file), so I don't understand what the error is trying to tell me.
I tried Windows (no addons) and macOS (Unity's iPhone and tvOS addons installed) and got the same error. After running the code, the Texture Import Inspector looks as expected.
Your answer
![](https://koobas.hobune.stream/wayback/20220613033049im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Handling 32-bit textures 0 Answers
Negative pixel inset removes ability for touch input on GUITexture 0 Answers
Change TextureType from Script 0 Answers
set minimum texture resolution? 2 Answers