Unity 5.5 EncodetoPNG with texture format deprecated.

Hi,

Unsupported texture format - needs to be ARGB32, RGBA32, RGB24, Alpha8 or one of float formats

This is the error I get when I try to encode something to png or jpg using EncodeToPNG or EncodeToJPG Functions. I was working with one of my old libraries from Unity 5.0. I see that textureImporter.textureFormat is deprecated so how could I encode a asset png/jpg without setting the format.

You now have to create an instance of TextureImporterPlatformSettings and set the format on it (along with other fields, including the platform) then call textureImporter.SetPlatformTextureSettings passing in the settings.

1 Like

Thanks :slight_smile: That works. So now users can’t customize the format directly on the importer ?

You still have full control in the inspector.

I mean this

as you can see I can’t set the format myself within the editor.

You can do it for your build targets though which is what is important.