GetPixels returning skewed results on DXT5 Texture

I’m making a 2D game in Unity, and I’m trying to use Texture2D.getPixels with a DXT5 compressed texture in order to make a spritesheet. It isn’t coming out quite right.

Here’s the original texture:

[7656-beacon%20neutral%20blue%206.png|7656]

And here’s what it looks like after using getPixels() to grab all of its colors, and write it into a new Texture:

7657-whoops.png

Any ideas as to why this might now be working? I’ve tried this with uncompressed images, and it’s worked just fine. It’s clearly grabbing the colors, but the resulting image is transformed somehow.

If you need more information, let me know.

EDIT:

I’m using a modified third party tool to create spritesheets and sprite animations in the editor. The sprites are grabbed from the spritesheet at runtime…which may be the solution to the main memory problem. If the actual animation frames aren’t needed after making the spritesheet, then I may not need to keep the textures in the editor. I’ll try that later and let you know if that works. I don’t know offhand if the tool needs the textures to remain in the editor after the spritesheet is built.

Back to the problem at hand: That one line of code is executed in the editor at development time. The texture I’m using is a NPOT .png, resolution 625x226.

The target platform for the game is PC, hypothetically XBox if we can get it done enough. I don’t think this matters too much, as we need the textures at development time.

Have you tried making it it non-power of 2 in the import settings?

Ideally if it’s going to be a 2D image like a sprite, change its import type to GUI.

I also seem to remember that only certain formats play nicely with GetPixels. ARGB32 and RGBA32 I’m fairly sure work, for example.

Well, this looks like your target texture’s width is off by one. Without seeing the code which you use to copy the image it’s impossible to say anything. GetPixels returns a “flattened 2D array”. What you see here is the typical case where you write a flattened array to a greater or smaller image. In this case i would guess the target size is one pixel larger than the source. That means each row has an additional pixel which originally was on the next row.