summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scene/resources/texture.cpp8
-rw-r--r--scene/resources/texture.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 3dc32632cc..80cab99373 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -1248,6 +1248,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 93f4e2de5a..862b9a47a6 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -250,6 +250,8 @@ public:
bool is_pixel_opaque(int p_x, int p_y) const override;
+ virtual Ref<Image> get_image() const override;
+
AtlasTexture();
};