It's a Unity3d specific question, but I thought I'd ask it here since I get no usefull feedback in the Unity forums.
In short; I need to get the corresponding TextureFormat
for any TextureImporterFormat
.
I'm writing an AssetPostprocessor
; I want to alter textures after they're imported, and then I want to compress them.
So in the OnPostprocessTexture(Texture2D texture)
function I want to compress the texture in the textureformat defined in the editor (in the TextureImporter
), like it would if I didn't do anything in this function.
However, the compression function (EditorUtility.CompressTexture()
) expects the format to be of type TextureFormat
, but the only format I can get is of type TextureImporterFormat
.
How do I get from the one to the other?
Or how can I avoid this problem alltogether?
I'm doing it manually now, which is a pain the ass. especially since it differs depending on the version of Unity, which also means it could change with any new Unity update. :(
I forgot about this question, kinda late but thought I should answer it anyway.
Turns out I was misinterpreting the results I got. Compression happens automatically after this function.
I had made a test to see if textures where being compressed after using OnPostprocessTexture(), and thought they weren't, but they are.