diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-03-10 14:09:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-10 14:09:17 +0100 |
commit | 9b597364737cbc04ccb5ee8e5c18bccb4dd31362 (patch) | |
tree | 5e2cc8006e77d01596e323ad9bac586920fc080a /core/io | |
parent | 90faf04f293fcdf636f641bfe3d88c5857695d9b (diff) | |
parent | 6f51eca1e3045571ccc68414a922e8b0229111f0 (diff) |
Merge pull request #58972 from reduz/expose-more-gdextension
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/resource.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 66d5c54b53..f90a6e9304 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -290,6 +290,21 @@ void Resource::_take_over_path(const String &p_path) { } RID Resource::get_rid() const { + if (get_script_instance()) { + Callable::CallError ce; + RID ret = get_script_instance()->callp(SNAME("_get_rid"), nullptr, 0, ce); + if (ce.error == Callable::CallError::CALL_OK && ret.is_valid()) { + return ret; + } + } + if (_get_extension() && _get_extension()->get_rid) { + RID ret; + ret.from_uint64(_get_extension()->get_rid(_get_extension_instance())); + if (ret.is_valid()) { + return ret; + } + } + return RID(); } @@ -428,6 +443,11 @@ void Resource::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resource_local_to_scene"), "set_local_to_scene", "is_local_to_scene"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "resource_path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_path", "get_path"); ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "resource_name"), "set_name", "get_name"); + + MethodInfo get_rid_bind("_get_rid"); + get_rid_bind.return_val.type = Variant::RID; + + ::ClassDB::add_virtual_method(get_class_static(), get_rid_bind, true, Vector<String>(), true); } Resource::Resource() : |