不幸的是,创建压缩纹理并不是可以在运行时合理完成的事情。 压缩格式旨在快速读取,但设计为在离线过程中写入。 换句话说,这不是你想在手机上做的事情。 此限制会影响生成的打包纹理,理论上可以压缩源纹理。 但是,如果您只压缩源纹理而无法压缩生成的打包纹理,则对于使用的大小没有多大帮助,只会使生成的打包纹理质量变差。
该调用可能会引发异常,因为纹理区域无法自由地复制到压缩纹理或从压缩纹理复制,因为压缩纹理以例如块的形式工作。 4x4 像素。 因此,您只能复制到正好位于 4x4 网格上的区域,例如 如果 32x32 块位于位置“(0, 2)”,则该块会失败。
Unfortunately creating compressed textures is not something that can be done reasonably at runtime. Compression formats are designed to be quick to read but are designed to be written in an offline process. In other words, it's not something you want to do on a phone. This limitation affects the resulting packed texture, the source texture could theoretically be compressed. However, if you only compress the source texture but can't compress the resulting packed texture, it would not help much in regards to used size but only make the resulting packed texture bad in quality.
The call likely throws an exception because texture regions can't be freely copied to or from a compressed texture, as compressed textures work in blocks of e.g. 4x4 pixels. So you could only copy to regions that lie exactly on the 4x4 grid, making e.g. a 32x32 block fail if it's located at location (0, 2)
.