I'm importing DDS textures from editor scripts and I need to access the GetPixels() method from each imported texture to check if the image have transparent pixels.

When importing the images by just creating the file inside the Unity project Assets folder from an editor script, the asset will have its isReadable property set to false which will cause an exception when executing GetPixels() (because isReadble is false).

The isReadble property is readonly from the Texture2D class. I read somewhere that I could use its TextureImporter class to set the property to true and re import the asset through AssetDatabase.ImportAsset(). The problem is that the importer used to import DDS images seems to be an implementation of IHVImageFormatImporter and the isReadable property there is readonly too.

As far as I checked IHVImageFormatImporter can't be converted to TextureImporter. So I left the question: in this case, how can I modify isReadable for imported DDS images?

Or maybe there is another way to be able to read those images from code without throwing an exception?

  • 2
    \$\begingroup\$ Does this or this address your question? \$\endgroup\$
    – Pikalek
    Commented Dec 22, 2020 at 21:31
  • \$\begingroup\$ First link did the job. Ty! \$\endgroup\$ Commented Dec 23, 2020 at 0:51


You must log in to answer this question.

Browse other questions tagged .