I am working on a jigsaw puzzle and it has lots of images. Usual compression methods do not work efficiently and I was exploring Crunch compression. This is really great and I am able to reduce texture size without compromising on quality much. But I am manipulating compressed textures in script (resizing and splitting images). So when I crunched compressed an image Unity throws an error when I tried to access that texture in the script. “crunch compressed textures can not be accessed from scripts”. Do we have any solution to this issue? or any workaround?
So I have found the solution to access Crunched compressed textures in the script. Unfortunately Unity’s scripting document about GetPixels() does not provide enough information on Crunch compressed texture. It simply says that GetPixels() does not support crunch compressed texture. However it does not mention that we can use GetPixels32() to work is around. It has been mentioned in GetPixels32() scripting reference. So if you want to access crunched compressed textures in your script, you first need to convert that to another format (I don’t know what it has been called). Use following code:
public Texture2D Convert(Texture2D crunchedImage)
Texture2D image = new Texture2D(crunchedImage.width, crunchedImage.height);
Now you can use this returning image in GetPixel() manipulations.
I know its an overhead but at least I don’t find any another way to access crunched textures. It is fine with me as I am working on a Jigsaw puzzle and need to access a single image at a time. But it could have performance implications if you have many images compressed using crunch compression and you need to accessed all of them at once (probably in one scene).