Repository navigation
fix(Texture2DArray): read the layers of streamed texture arrays - #391
nichinichisou0609 wants to merge 1 commit into
Conversation
| ) -> Image.Image: | ||
| """Converts the given Texture2D object to PIL Image.""" | ||
| if not texture_2d.m_Width or not texture_2d.m_Height: | ||
| return Image.new("RGBA", (0, 0)) |
There was a problem hiding this comment.
This check is not necessary, as parse_image_data already does it.
There was a problem hiding this comment.
Removed, thanks!
Small heads-up in case it matters: get_image_data() runs before parse_image_data, so a 0x0 texture without data now raises ValueError("No image data found") (same as after #395) instead of returning an empty image. Either is fine for me.
| @@ -0,0 +1,104 @@ | |||
| from types import SimpleNamespace | |||
There was a problem hiding this comment.
While correct in theory,
the test here is completely engineered on scope,
and might therefore not the real world scenario.
So, please remove it test.
Long term I plan to add a bunch of self made samples covering all directly supported special object classes.
There was a problem hiding this comment.
Sure, removed it. I attached a small sample below instead, in case it's useful when you set up the sample tests.
Texture2DArray.images only read m_StreamData when image_data was None. A streamed array serializes image_data as an empty byte string, so the resource file was never read and every streamed array failed with "Texture2D has no image data". Texture2DArray now has get_image_data(), with the same rules as Texture2D.get_image_data(): the inline data when there is any, else the resource named by m_StreamData, else a ValueError. images uses it and decodes the layers with the platform of the object reader instead of platform 0, as Texture2D does.
f8906d7 to
2715f0c
Compare
|
Rebased on master. #395 already covers the I also switched the In case you want a sample for it: the zip has a tiny AssetBundle with one streamed Texture2DArray, built from an empty Unity 2022.3 project (the build script is included). Feel free to ignore it if you'd rather build your own. |
Texture2DArray.imagesonly readm_StreamDatawhenimage_datawasNone. A streamed array serializesimage_dataas an empty byte string, so its resource file was never read and every streamed array failed withTexture2D has no image data.Texture2DArraygets aget_image_data()with the same rules asTexture2D.get_image_data(): the inline data if there is any, else the resource named bym_StreamData, elseValueError("No image data found").imagesdecodes the layers with the object reader's platform instead of0, asTexture2Ddoes.The
Texture2Dhalf of this PR is already on master through #395.