diff options
author | boruok <burutarunootoko@gmail.com> | 2021-09-28 23:54:47 +0900 |
---|---|---|
committer | boruok <burutarunootoko@gmail.com> | 2021-09-28 23:54:47 +0900 |
commit | 2cc2adedaaf4a0c99915c781b68ccb6b17e59a98 (patch) | |
tree | d2ffbbf6ad549feb8d7ec4b5fd4c3b7b111f984c | |
parent | 7cdd8629ad4c2994c7882fe2c1dccd29ce5dec2c (diff) |
4.0 fix atlas texture return null
-rw-r--r-- | scene/resources/texture.cpp | 8 | ||||
-rw-r--r-- | scene/resources/texture.h | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 063a13efc0..76b322dc8c 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -1272,6 +1272,14 @@ bool AtlasTexture::is_pixel_opaque(int p_x, int p_y) const { return atlas->is_pixel_opaque(x, y); } +Ref<Image> AtlasTexture::get_image() const { + if (!atlas.is_valid()) { + return Ref<Image>(); + } + + return atlas->get_image()->get_rect(region); +} + AtlasTexture::AtlasTexture() {} ///////////////////////////////////////// diff --git a/scene/resources/texture.h b/scene/resources/texture.h index f6b991c335..576c053c25 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -252,6 +252,8 @@ public: bool is_pixel_opaque(int p_x, int p_y) const override; + virtual Ref<Image> get_image() const override; + AtlasTexture(); }; |