- Home /
"Non power of 2" Textures - How to access original size?
Hi,
I am building some kind of virtual museum with Unity. All the original paintings I want to show are not power of 2, so I chose the option "toSmaller" in the Texture Importer to keep the performace high. The problem is: Within the game, I also want to show the paintings as 2D Textures, so I will have to access their original texture width and height. By now, the paintings are distorted, because the textures are saved as 512 x 1024 or something like this. So, a statement like:
print("Size is " + painting.width + " by " + painting.height);
gives me 512 x 1024, but not the original size. Is it possible to access the texture's origial size?
Well, what's the file type before you put it in to Unity? Can't you just check the old files?
The file type is jpg. $$anonymous$$y problem is, how can I check the original file's dimensions during runtime?
Answer by taoa · Dec 23, 2010 at 03:18 PM
I would set those texture as 'GUI' so that they don't get resized at all. But if you absolutely need them to be power of 2 for memory usage issues, then got for the duplication solution, have one version 'power of 2' and one version 'GUI', switch to the latter when you're going for quality.
Answer by Oinobareion · Dec 24, 2010 at 01:26 PM
I am not sure, what you mean by setting the texture as 'GUI'. Can you explain that? Thanks a lot!
If you click the file in the project pane in Unity, you get import options for that texture in the inspector. Under "Texture Type", there's an option called "GUI". If you select that, Unity will not resize your texture at all.
Answer by StephanK · Dec 23, 2010 at 01:46 PM
Easiest way to solve this is to duplicate the texture asset and set the power of 2 option to none, then use that one for your undistorted textures and the other one for the rest.