Skip to content

Commit 14fb935

Browse files
Expose ResourceLoader::get_resource_type and ResourceLoader::get_resource_script_class
Co-Authored-By: Pedro J. Estébanez <RandomShaper@users.noreply.github.com>
1 parent 47bc374 commit 14fb935

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

core/core_bind.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ ResourceUID::ID ResourceLoader::get_resource_uid(const String &p_path) {
132132
return ::ResourceLoader::get_resource_uid(p_path);
133133
}
134134

135+
String ResourceLoader::get_resource_type(const String &p_path) {
136+
return ::ResourceLoader::get_resource_type(p_path);
137+
}
138+
139+
String ResourceLoader::get_resource_script_class(const String &p_path) {
140+
return ::ResourceLoader::get_resource_script_class(p_path);
141+
}
142+
135143
Vector<String> ResourceLoader::list_directory(const String &p_directory) {
136144
return ::ResourceLoader::list_directory(p_directory);
137145
}
@@ -151,6 +159,8 @@ void ResourceLoader::_bind_methods() {
151159
ClassDB::bind_method(D_METHOD("get_cached_ref", "path"), &ResourceLoader::get_cached_ref);
152160
ClassDB::bind_method(D_METHOD("exists", "path", "type_hint"), &ResourceLoader::exists, DEFVAL(""));
153161
ClassDB::bind_method(D_METHOD("get_resource_uid", "path"), &ResourceLoader::get_resource_uid);
162+
ClassDB::bind_method(D_METHOD("get_resource_type", "path"), &ResourceLoader::get_resource_type);
163+
ClassDB::bind_method(D_METHOD("get_resource_script_class", "path"), &ResourceLoader::get_resource_script_class);
154164
ClassDB::bind_method(D_METHOD("list_directory", "directory_path"), &ResourceLoader::list_directory);
155165

156166
BIND_ENUM_CONSTANT(THREAD_LOAD_INVALID_RESOURCE);

core/core_bind.h

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class ResourceLoader : public Object {
8585
Ref<Resource> get_cached_ref(const String &p_path);
8686
bool exists(const String &p_path, const String &p_type_hint = "");
8787
ResourceUID::ID get_resource_uid(const String &p_path);
88+
String get_resource_type(const String &p_path);
89+
String get_resource_script_class(const String &p_path);
8890

8991
Vector<String> list_directory(const String &p_directory);
9092

doc/classes/ResourceLoader.xml

+15
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@
6060
Returns the list of recognized extensions for a resource type.
6161
</description>
6262
</method>
63+
<method name="get_resource_script_class">
64+
<return type="String" />
65+
<param index="0" name="path" type="String" />
66+
<description>
67+
Returns the global script class name a given [param path], as set by the [code]class_name[/code] keyword in GDScript or the [code][GlobalClass][/code] attribute in C#.
68+
If there is none, it returns an empty string.
69+
</description>
70+
</method>
71+
<method name="get_resource_type">
72+
<return type="String" />
73+
<param index="0" name="path" type="String" />
74+
<description>
75+
Returns the type of the resource at the given [param path].
76+
</description>
77+
</method>
6378
<method name="get_resource_uid">
6479
<return type="int" />
6580
<param index="0" name="path" type="String" />

0 commit comments

Comments
 (0)