diff options
-rw-r--r-- | scene/resources/texture.cpp | 18 | ||||
-rw-r--r-- | scene/resources/texture.h | 5 |
2 files changed, 23 insertions, 0 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index e001aeffc4..815343b044 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -147,6 +147,24 @@ void ImageTexture::reload_from_file() { } } +bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) { + if (p_name == "image") { + create_from_image(p_value); + } + return false; +} + +bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const { + if (p_name == "image") { + r_ret = get_image(); + } + return false; +} + +void ImageTexture::_get_property_list(List<PropertyInfo> *p_list) const { + p_list->push_back(PropertyInfo(Variant::OBJECT, PNAME("image"), PROPERTY_HINT_RESOURCE_TYPE, "Image", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)); +} + void ImageTexture::create_from_image(const Ref<Image> &p_image) { ERR_FAIL_COND_MSG(p_image.is_null() || p_image->is_empty(), "Invalid image"); w = p_image->get_width(); diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 3e8ac060c4..317756e313 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -102,6 +102,11 @@ class ImageTexture : public Texture2D { protected: virtual void reload_from_file() override; + + bool _set(const StringName &p_name, const Variant &p_value); + bool _get(const StringName &p_name, Variant &r_ret) const; + void _get_property_list(List<PropertyInfo> *p_list) const; + static void _bind_methods(); public: |